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! Quote Link to comment 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; Quote Link to comment Share on other sites More sharing options...
benphp Posted November 11, 2008 Author Share Posted November 11, 2008 Excellent! THank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.