An7hony Posted November 23, 2012 Share Posted November 23, 2012 Hi Guys I am trying to match the usernames from 2 tables but then only show the usernames that are not matched (the rows: users and candidate_name both hold usernames) $query1 = "SELECT users FROM users"; $query2 = "SELECT candidate_name FROM applied_jobs"; Can anyone teach me how to do this? Thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/271080-match-the-usernames-from-2-tables/ Share on other sites More sharing options...
An7hony Posted November 23, 2012 Author Share Posted November 23, 2012 Think this has worked $q = "SELECT username FROM users WHERE NOT EXISTS (SELECT candidate_name FROM applied_jobs WHERE candidate_name = username)"; Quote Link to comment https://forums.phpfreaks.com/topic/271080-match-the-usernames-from-2-tables/#findComment-1394641 Share on other sites More sharing options...
spfoonnewb Posted November 23, 2012 Share Posted November 23, 2012 Here is another typical solution for this: SELECT users.username FROM users LEFT JOIN applied_jobs ON users.username = applied_jobs.candidate_name WHERE applied_jobs.candidate_name IS NULL Quote Link to comment https://forums.phpfreaks.com/topic/271080-match-the-usernames-from-2-tables/#findComment-1394655 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.