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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.