hi everyone, i am trying to compare 2 tables and return the difference, i can join the tables (no problem there), but can`t get the difference in the 2. to clarify my problem, table1 has company_id as does table2 but table 2 does not have ALL the company_id`s as table 1 has, now i am wanting to find out the company_id`s that do not match. this is what i am currently trying, i am not getting any errors, all i am getting is the company_id`s that DO match.
Code:
$query=mysql_query("SELECT * from company as c1
INNER JOIN
messages as c2
on c1.company_id=c2.company_id where c1.company_id != ''") or die (mysql_error());
SELECT c1.company_id
from company as c1
LEFT JOIN messages as c2
on c1.company_id=c2.company_id
where c2.company_id is null
__________________
Found a flower or bug and don't know what it is ? agrozoo.net galery
if you don't spot search button at once, there is search form: agrozoo.net galery search
Last edited by BubikolRamios; 12-12-2012 at 08:16 AM..
when i use c1.company_id or the * i get either ALL the id`s from the company table or ALL the id`s that do match. this is using either the LEFT JOIN or RIGHT JOIN, doesnt matter which one i use. i have tried ever way using left and right join and nothing is giving the right results
__________________
Found a flower or bug and don't know what it is ? agrozoo.net galery
if you don't spot search button at once, there is search form: agrozoo.net galery search
when i tried that earlier it wouldnt give any results but just tried it again and now it works!! ty so much, now to figure out how to get the company_name to show up in a drop down. lol always something, eh?