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 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)"; 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 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
Archived
This topic is now archived and is closed to further replies.