There is Table A and B
item_serial_no (Table A) | forbidden_item_serial_no (Table B)
-------------- | --------------
1 | 1
2 | 3
3 | 5
4 | 7
5
6
7
When I use SQL:
SELECT
A.item_serial_no
FROM
A
INNER JOIN B ON A.item_serial_no = B.forbidden_item_serial_no
I will get 1,3,5,7.
But I would like to get negation of it, so the result would be like:
result query
------------
2
4
6
I am not SQL ninja and I have spent prety much time to solve this, but no success.
Thanx for help
>Solution :
One way of doing this is to use a LEFT JOIN:
SELECT
A.item_serial_no
FROM
A
LEFT JOIN B ON A.item_serial_no = B.forbidden_item_serial_no
WHERE B.forbidden_item_serial_no IS NULL