Page 1 of 1

Find the odd one out - Urgent

Posted: Wed Jul 21, 2004 7:01 am
by Stryks
Hi all,

I have two database tables that should have the same number of values in them, but one has one value too many.

I need to find a query which can tell me which one is not in both tables.

Can anyone tell me how to do this?

The value which should match for both is category_id

Thanks

Posted: Wed Jul 21, 2004 7:03 am
by kettle_drum
Hmmm.

Code: Select all

SELECT * FROM table, table2 WHERE table1.value <> table2.value

Posted: Wed Jul 21, 2004 7:06 am
by Stryks
Well ... thats what I thought.

There are 2847 in one table and 2848 in the other. Using that query returns 8128201 values.

Go figure.

Any other ideas?

Posted: Wed Jul 21, 2004 7:24 am
by markl999

Posted: Wed Jul 21, 2004 8:23 am
by liljester

Code: Select all

SELECT big_table.*, small_table.* FROM big_table LEFT JOIN small_table ON big_table.id = small_table.id WHERE small_table.id IS NULL