baddkar Posted September 20, 2007 Share Posted September 20, 2007 Basically I have two tables like so. TBL1 NAME (20 values) TBL2 WEEK aNAME bNAME Each week there is 5 different combos with aNAME and bNAME. TBL2 names are the same names used in TBL1. If for week one 10 of the 20 names are listed together. (aNAME w/ bNAME) All I want is to be able to display the other 10 names from TBL1 that weren't paired, below the list of users from TBL2 Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/69987-comparing-data-on-two-tables/ Share on other sites More sharing options...
Illusion Posted September 20, 2007 Share Posted September 20, 2007 Try this Select a.name from tbl1 as a,tbl2 as b where a.name !=b.aname OR a.name !=b.bname; Quote Link to comment https://forums.phpfreaks.com/topic/69987-comparing-data-on-two-tables/#findComment-351565 Share on other sites More sharing options...
Barand Posted September 21, 2007 Share Posted September 21, 2007 SELECT a.name FROM tbl1 a WHERE a.name NOT IN (SELECT namea FROM tbl2 WHERE week = 1) AND a.name NOT IN (SELECT nameb FROM tbl2 WHERE week = 1) or, without subqueries, SELECT a.name FROM tbl1 a LEFT JOIN tbl2 b ON a.name = b.namea LEFT JOIN tbl2 c ON a.name = c.nameb WHERE b.namea IS NULL AND c.nameb IS NULL Quote Link to comment https://forums.phpfreaks.com/topic/69987-comparing-data-on-two-tables/#findComment-351951 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.