473,383 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

MySQL 'IN' Operator Syntax

Hello,

I'm learning about MySQL but i'm having problems with the 'IN'
operator. For example:

SELECT * FROM TABLE_NAME WHERE ID = IN ('9','19','3','10');

....gives me a syntax error. I've also tried it with (9,19,3,10) but it
gives me the same problem.

I have a feeling i'm missing something very simple.

Any pointers would be greatly appreciated.

Many Thanks.
Jul 20 '05 #1
4 41495
Obi Wan Shinobi wrote:
I'm learning about MySQL but i'm having problems with the 'IN'
operator. For example:

SELECT * FROM TABLE_NAME WHERE ID = IN ('9','19','3','10');

...gives me a syntax error. I've also tried it with (9,19,3,10) but it
gives me the same problem.


Get rid of the = so it reads like:

SELECT * FROM TABLE_NAME WHERE ID IN (9,19,3,10);

Chris

--
Chris Hope
The Electric Toolbox Ltd
http://www.electrictoolbox.com/
Jul 20 '05 #2
Obi Wan Shinobi wrote:
I'm learning about MySQL but i'm having problems with the 'IN'
operator. For example:

SELECT * FROM TABLE_NAME WHERE ID = IN ('9','19','3','10');

...gives me a syntax error. I've also tried it with (9,19,3,10) but it
gives me the same problem.


Get rid of the = so it reads like:

SELECT * FROM TABLE_NAME WHERE ID IN (9,19,3,10);

Chris

--
Chris Hope
The Electric Toolbox Ltd
http://www.electrictoolbox.com/
Jul 20 '05 #3
Obi Wan Shinobi wrote:
I'm learning about MySQL but i'm having problems with the 'IN'
operator. For example:

SELECT * FROM TABLE_NAME WHERE ID = IN ('9','19','3','10');

...gives me a syntax error. I've also tried it with (9,19,3,10) but it
gives me the same problem.


Get rid of the = so it reads like:

SELECT * FROM TABLE_NAME WHERE ID IN (9,19,3,10);

Chris

--
Chris Hope
The Electric Toolbox Ltd
http://www.electrictoolbox.com/
Jul 20 '05 #4
Obi Wan Shinobi wrote:
SELECT * FROM TABLE_NAME WHERE ID = IN ('9','19','3','10');


Don't use = with IN. For example:
SELECT * FROM TABLE_NAME WHERE ID IN ('9','19','3','10');

See http://dev.mysql.com/doc/mysql/en/Co...Operators.html, this
lists all the syntax for comparison operations.

Regards,
Bill K.

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: cocoalearner | last post by:
I am serving a website using apache. All the php and mysql code I have written works, except for one thing. When I try to create a database named M#2 using the following call, no database is...
2
by: Paul Escherton | last post by:
I'm trying to templatize the operator(), but VisualStudio .NET 2003 I get an odd error. I'm wondering if there is a way to do this and what the proper syntax is. If there is not, why not? My...
5
by: red85 | last post by:
hello i have mysql 4.1 with win2000 SP3, i know that it is only an alpha and i don't know if someone else has already posted this problem: when i execute this sql UPDATE tableX SET...
0
by: Fatt Shin | last post by:
Hi, I'm running MySQL 4.0.13, connecting from PowerBuilder 9 using ODCB Connector 3.51. I'm facing a problem where whenever I issue a SELECT COUNT(*) statement from PowerBuilder, I always get SQL...
0
by: Mario Ohnewald | last post by:
Hello! I want to import a MySQL 3.x Databse to my new shiny MySQL4.x. I did a backup with /usr/local/mysql-standard-4.0.14-pc-linux-i686/bin/mysqldump -u root -p --opt -A > mysql_lamp_backup.`date...
13
by: wideangle | last post by:
Hello there! I know it's stupid, but when creating a table in a mysql (win32) database, it won't let me create this "mytable". Here goes my ER_PARSE_ERROR. mysql> CREATE TABLE `mytable` ( ->...
5
by: Rob | last post by:
To follow up on the "copy constructor clarification thread"... The assignment operator syntax shown previously: MyClass% operator=(const MyClass%); seems to have problems if you have member...
12
by: howa | last post by:
any side effect for PHP? what do you think?
1
ssnaik84
by: ssnaik84 | last post by:
Hi Guys, Last year I got a chance to work with R&D team, which was working on DB scripts conversion.. Though there is migration tool available, it converts only tables and constraints.. Rest of...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.