SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot yukimushu's Avatar
    Join Date
    Feb 2005
    Location
    United Kingdom
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Left Join nightmare

    I'm very new to all this Left Join stuff; I think I understand how it works, I just can't get this below statement to work, i've spent hours trying to figure it out lol.

    Tables:

    == Prod ==
    pid - (id of product)
    title - (product title)

    == Gift Joins ==
    pid (id of product in Prod table)
    oid (gift occasion id)


    Code MySQL:
    SELECT
    	p.pid,
    	p.title,
    	g.oid,
    	g.pid
    FROM
    	prod AS p,
    	giftjoins AS g
    LEFT JOIN
    	giftjoins
    ON p.pid = g.pid WHERE p.pid = g.pid

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    700
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Code:
    SELECT
        p.pid,
        p.title,
        g.oid,
        g.pid
    FROM
        prod AS p
    LEFT JOIN
        giftjoins as g
    ON p.pid = g.pid

  3. #3
    SitePoint Zealot yukimushu's Avatar
    Join Date
    Feb 2005
    Location
    United Kingdom
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by swampBoogie View Post
    Code:
    SELECT
        p.pid,
        p.title,
        g.oid,
        g.pid
    FROM
        prod AS p
    LEFT JOIN
        giftjoins as g
    ON p.pid = g.pid
    You sir, are a legend Thank's alot! *bows to swampBoogie*


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
  •