> I want to show a list of records from one table, along with related
> data from a second table. I need every record from the first table, but
> am only interested in data from the second table that have a given user
> id.

It sounds like you want a left join with an optional filter, something along
the lines of:

SELECT * FROM category c
LEFT JOIN selection s ON s.CategoryID = c.CategoryID 
WHERE s.UserID IS NULL OR s.UserID = [x]
ORDER BY CategoryID, s.UserID

(Untested, but you get the idea).


-Justin



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/sql/message.cfm/messageid:3275
Subscription: http://www.houseoffusion.com/groups/sql/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.6

Reply via email to