tags:

views:

14

answers:

1

Hi all, i know it may be very simple query, but please help me out.

    i have item id 1,2,3,4 etc.... 

now i want to get all row regrading that item id what will be mysql query?? i used IN operator but this return only one row

SELECT item_id,item_name FROM tbl_item_detail WHERE item_id IN('1,3,4')

my table structure is below

item_id | item_name |.....
  1     |  first    |
  2     |  second   |
  3     |  third    |
  4     |  fourth   |

. .

which operator i have to use?or what will be perfect query for this?

+1  A: 

After firing this query, mysql would have returned two things:
1. The item_id, item_name of the row with id 1 in the tbl_item_detail table.
2. A warning after the above result like, '1 row in set, 3 warnings (0.00sec)'.

The warning message means that there was a problem in your query, and mysql could only partially understand it. Your query was:

SELECT item_id,item_name FROM tbl_item_detail WHERE item_id IN('1,3,4');

It should actually be:

SELECT item_id,item_name FROM tbl_item_detail WHERE item_id IN(1,3,4);

OR

SELECT item_id,item_name FROM tbl_item_detail WHERE item_id IN('1','3','4');

I believe the rest is self explanatory.

Shrinivas
Thanks sir, i was doing mistakes . thanks for pointing
diEcho
Glad I could help, Cheers.
Shrinivas