Given 2 tables, TableA and TableB, how can I get the “id”s of TableA when the “value” doesn’t match with any “value” of TableB?
Table A
+----+-------+
| id | value |
+----+-------+
| 1 | a |
| 2 | b |
| 3 | c |
| 4 | d |
| 5 | e |
+----+-------+
Table B
+----+-------+
| id | value |
+----+-------+
| 1 | a |
| 2 | b |
| 3 | c |
| 4 | c |
| 5 | f |
+----+-------+
Result Table
+----+
| id |
+----+
| 4 |
| 5 |
+----+
EDITED (SQLFiddle): http://sqlfiddle.com/#!2/4c8c9
If you want to validate that the id/value are the same in both tables then use:
See SQL Fiddle with Demo
If you want to compare only the values:
See SQL Fiddle with Demo