SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Get results regardless of record existence

  1. #1
    SitePoint Zealot
    Join Date
    Jul 2007
    Posts
    169
    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 silver trophybronze trophy
    SitePoint Award Recipient r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    38,462
    Mentioned
    35 Post(s)
    Tagged
    1 Thread(s)
    use a LEFT OUTER JOIN

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

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2007
    Posts
    169
    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
  •