benphp Posted November 11, 2008 Share Posted November 11, 2008 I have 2 tables, "users" and "resp". users: Last | First | uid resp: val1 | val2 | uid I want to find out who in "users" does not have a record in "resp". I've tried: SELECT DISTINCT users.first, users.last FROM users RIGHT JOIN resp ON users.uid = resp.uid WHERE resp.uid IS NULL; but it doesn't work of course. How do I do this? Thanks! Link to comment https://forums.phpfreaks.com/topic/132324-solved-how-to-compare-values-that-dont-exist-in-one-table/ Share on other sites More sharing options...
fenway Posted November 11, 2008 Share Posted November 11, 2008 Very close -- but you really should name those uid fields "user_uid" to make it clear: SELECT u.first, u.last FROM users AS u LEFT JOIN resp AS r ON r.uid = u.uid WHERE r.uid IS NULL; Link to comment https://forums.phpfreaks.com/topic/132324-solved-how-to-compare-values-that-dont-exist-in-one-table/#findComment-687958 Share on other sites More sharing options...
benphp Posted November 11, 2008 Author Share Posted November 11, 2008 Excellent! THank you! Link to comment https://forums.phpfreaks.com/topic/132324-solved-how-to-compare-values-that-dont-exist-in-one-table/#findComment-687978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.