Sorry for total noobishness, but I'm trying to write SQL for the following problem involving a mysql database and I'm at a loss.
Here's the problem. Given the following two tables:
**Table1** PID WEBSITE COMP_SITE KEYCODE SITE_TYPE KEYWORDS 14 google.com bing.com w3874yf8 alpha happy+campers 26 radio.com alice.com 98ygdsfg beta slip+slop 13 simon.com fat.org 98dfyg77 delta sunrise **Table2** PID WEBSITE KEYWORDS 14 google.com happy+campers 14 yahoo.com fat+albert 14 aol.com chump+change
I want a query to return EVERY row in Table1 for which there are NO rows in Table2 matching the same (ID,WEBSITE,KEYWORDS) chunk of the row. In the above example this query would return rows 2 and 3 of Table1.
Note that no columns in either table containing individual values unique to the table, though the ID/WEBSITE/KEYWORDS chunk of a row will be unique.
I feel I'm making this far more complicated than it need to be. :/
select * from Table1 as t1 left join Table2 as t2 on t1.PID =t2.PID and t1.WEBSITE =t2.WEBSITE and t1.KEYWORDS = t2.KEYWORDS where t2.PID is null