SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jul 2005
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Advance Query Related Question

    I have 2 Tables as follows:
    PHP Code:
    Just for Illustrationnot PHP Code...
    Table 1:
    Fields:   Car ID   |   Car Maker   |   Car Model
    Records
    :    1      |   Honda       |   Accord

    Table 2
    :
    Fields:   ID   |   Car ID   |   Engine
    Records
    :   1   |      1     |     V4 
    Records
    :   2   |      1     |     V6
    Records
    :   3   |      1     |     V8 
    Table 1 has single entry & Table 2 has multiple entry for Honda Car.

    My question is what kind of query do I have to do which joins 2 Table by Car ID and reads single entry from Table 1 & multiple entry from Table 2.

    Thanks.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Code:
    select Table1.CarID
         , Table1.CarMaker
         , Table1.CarModel
         , Table2.Engine
      from Table1
    inner
      join Table2
        on Table2.CarID = Table1.CarID
    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
  •