Click to See Complete Forum and Search --> : JOINS -> Getting "outer" data


benf101
02-22-2009, 05:52 PM
Sorry if that title didn't make sense... it was the best way I could describe it.

I must have a fundamental misunderstanding of joins because my query is just returning everything except what I'm looking for.

I have 2 tables.

usersRss:
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| username | varchar(50) | NO | PRI | | |
| rssID | int(11) | NO | PRI | 0 | |
+----------+-------------+------+-----+---------+-------+

and rssSources;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| source | varchar(255) | YES | | NULL | |
| description | varchar(255) | YES | | NULL | |
+-------------+--------------+------+-----+---------+----------------+


I want to get the RSS sources whose ID is NOT in the usersRss table. I THOUGHT that meant to do an "outer" join. Apparently, I'm wrong.

Correct me where I'm wrong:
SELECT *
FROM usersRss OUTER JOIN rssSources
on usersRss.rssID = rssSources.id
WHERE usersRss.username = '$username';

I've tried left, right, outer, and every other combo I can think of. Any suggestions?

benf101
02-22-2009, 06:14 PM
Ok I fixed it.

Just select all the data and use php to filter it out. Done.

chazzy
02-22-2009, 10:07 PM
your request doesn't really make much sense but wouldn't it just be..


select * from rssSources where id not in (select distinct rssID from usersRss)