PHP query help

Discussion in 'PHP' started by tom007, Jan 22, 2007.

  1. #1
    I have two tables

    Table 1 has 3 unique URL (for e.g. hotmail.com) and Table 2 has 4 records of (hotmail.com)...The only way to display the combination for a particular URL is to use group by.

    Table 1

    id url
    1 hotmail.com
    2 sitepoint.com
    3 youtube.com

    Table 2
    id userid (user who added) url notes
    1 user1 hotmail.com good site
    2. user2 hotmail.com email site
    3. user3 hotmail.com great site
    4. user4 hotmail.com cool site


    Now I want to JOIN table 1 and table 2 and display unique records for hotmail.com...Only way i can do is by using group by...I don't want to use that. And it doesn't really matter if it display record by any user, but as long as it is only one record for hotmail.com in Table 2

    Can anyone please help me

    If I use inner join from Table 1 to table 2 ON URL, it still shows 4 records of that url, though i only want to show the first one if repeat record occur.
     
    tom007, Jan 22, 2007 IP
  2. jgarrison

    jgarrison Peon

    Messages:
    66
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    MySQL:

    SELECT one.id, one.url, two.notes
    FROM one, two
    WHERE one.id = two.id
    LIMIT 1
     
    jgarrison, Jan 22, 2007 IP