Jump to content

khawaib

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

khawaib's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I have two tables of data and I am trying to get the rows of one table that are not matching in other table. Not sure how to do that. For example: Table __a: id user1_id user2_id 1 5 7 Table __users: id username 5 a 6 b 7 c I need a query that should return me rwo 2 from Table 2 as it does not have matching row in table 1. I tried this but it does not return expected result: Code: $q = 'SELECT u.id, u.username FROM __users u '; $q .= 'LEFT JOIN __a a1 ON (u.id = a1.user1_id OR u.id = a1.user2_id) '; $q .= 'WHERE a1.user1_id = u.id OR a1.user2_id = u.id LIMIT 10'; Any help much appreciated. Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.