Jump to content

Comparing two databases


e1seix

Recommended Posts

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

..... 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";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.