Page 1 of 1

Get values of one MySQL table that are not in other table

Posted: 05 Dec 2014, 15:04
by Marius
Hello,
I have two tables: A and B. I need to compare their columns to get values of one table that are not in other table.
  • Table A columns : ID, table_id (key reference to table B), data
    Table B columns : ID (primary key, references to table A), x, y
I need to get values from A.table_id that are not equal to B.ID

Code: Select all

A.table_id values = 3,3,2
B.ID values = 1,2,3
I need to get value 1.

Get values of one MySQL table that are not in other table

Posted: 05 Dec 2014, 15:08
by Admin
Hi,
You can use not in:

Code: Select all

SELECT *
FROM table_A 
WHERE table_id NOT IN (SELECT id from table_B)