Joining 2 tables
| From: | Scott Gines | Date: | Fri, 10 Aug 2001 16:30:20 +0000 |
| Subject: | Joining 2 tables | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-11229@lists.php.net to get a copy of this message | ||
I am having trouble getting the correct join...here is my scenario.
I have 2 tables, A and B.
A looks something like this...
[id] [name]
1 Name1
2 Name2
3 Name3
B looks like this...
[userid] [tableAid]
1 1
1 3
2 1
2 2
I am looking for a join that will return only the items NOT found in table B
from table A. In this example, it would return 2/Name2 from table A for
userid 1.
This is my current statement:
select id, name from A left join A on A.id=B.tableAid where B.userid=1;
This gives me just the opposite of what I want.