SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Join Query

Hybrid View

  1. #1
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,891
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Join Query

    Hey,
    If I have two tables one called products and one called locations. One product can be in one location but each location can have many products. Each product record has a location id pointing to a location in the location table.

    How can I use a join query to say select product.name where location = <nameoflocation> ?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    Code:
    SELECT products.name
      FROM locations
    INNER
      JOIN products
        ON products.location_id = locations.id
     WHERE locations.name = 'timbuktu'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •