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