views:

20

answers:

2

Hello,

How can I query data from a table available on a list of strings?

I only want to get the data from the list of strings.

Example:
Table
ID Name
1  Big
2  Small
3  Extra
4  Orange
5  Drink

List of Strings:
Big
Small
Extra

Thanks!

+1  A: 
SELECT * FROM theTable WHERE column_name IN ('Big', 'Small', 'Extra')
egrunin
+2  A: 

I assume you want the MySQL IN clause:

SELECT ID, Name FROM TableName WHERE Name IN ('Big','Small','Extra')
Matthew Jones
Wow, what will MySQL do if you try to name a table `table`?
egrunin
+1 even though you were 9 seconds slower... for using an explicit list of columns in the select clause.
Mark Byers
FWIW, I started with an explicit list, but figured the OP must have other columns he wasn't showing us, and that he needed all the help he could get...
egrunin