SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2007
    Posts
    170
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Get results regardless of record existence

    Hi,

    How do I retrieve record from the following regardless of whether there is result in tableB?

    PHP Code:
    tableA
    +------+-----------+
    |  
    id  |  Article  |
    +------+-----------+
    |  
    1   |  Learn    |
    +------+-----------+
    |  
    2   |  Learn B  |
    +------+-----------+

    tableB
    +------+-------------+
    id   |  articleID  |
    +------+-------------+
    |  
    1   |      1      |
    +------+-------------+

    Select from tableA where tableA.id tableB.articleID
    The result I wanted is to retrieve all tableA articles regardless of whether there is a linkage in tableB?

    Thx in advanced.
    I Dunno LOL \(_o)/

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,215
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    use a LEFT OUTER JOIN

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2007
    Posts
    170
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    use a LEFT OUTER JOIN

    Oh thanks Rudy! It works! Your' a life saver!
    I Dunno LOL \(_o)/


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
  •