e1seix Posted August 24, 2010 Share Posted August 24, 2010 Don't let the title mislead you. I am looking to compare two databases, however I don't think using inner join is the way forward. Two databases: brands (a) and celebrities (b). I'm using a select statement to query which "brand" in brands (a) are not present already in celebrities (b). "brand" is the shared column between the databases. The closest thing I can come up with (but doesn't work) is: $query = 'SELECT a.brand, b.brand FROM brands a INNER JOIN celebrities b ON a.brand != b.brand ORDER BY brand'; Obviously this doesn't work because there is no joint column declared next to ON. How do I correct this? Link to comment https://forums.phpfreaks.com/topic/211655-comparing-two-databases/ Share on other sites More sharing options...
mikosiko Posted August 25, 2010 Share Posted August 25, 2010 ..... I am looking to compare two databases...... Two databases: brands (a) and celebrities (b). I'm using a select statement to query which "brand" in brands (a) are not present already in celebrities (b). "brand" is the shared column between the databases. The closest thing I can come up with (but doesn't work) is: $query = 'SELECT a.brand, b.brand FROM brands a INNER JOIN celebrities b ON a.brand != b.brand ORDER BY brand'; just a terminology fix first.... you are trying to compare 2 tables ... no 2 databases .. different concepts. try this (no tested but should work) $query = "SELECT a.brand, b.brand FROM brands a LEFT JOIN celebrities b ON a.brand = b.brand WHERE b.brand is NULL ORDER BY a.brand"; Link to comment https://forums.phpfreaks.com/topic/211655-comparing-two-databases/#findComment-1103387 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.