Results 1 to 2 of 2

Thread: select * from

  1. #1
    Join Date
    May 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question select * from

    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?

    10k's

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Try the following SQL statement

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •