View Full Version : select * from

sasha hantz
09-03-2007, 02:57 PM
:confused: i got 2 tables
table 1 called "products" and it got 2 columns : "name" and "loc"
table 2 called "locations" with 2 columns : "id" and "loc"

i need to run search in the products table
i need to find all the records from table "products" that got in their "loc" column
the same locations as in the locations table from row id 7 to id 9

for example if table location -id=7 loc=usa
id=8 loc=uk
id=9 loc=canada
i want to get from the products table all the record where the column "loc"
have usa or uk or canada...

mySQL="SELECT * FROM products WHERE loc=("SELECT * FROM Locations where id>1 and id<10 )
i wrote this select line but it not working...where i got wrong?


09-05-2007, 04:48 AM
Try the following SQL statement

select * from products where loc in (select loc from locations where id > 1 and id < 10)