-3
TABLE A
===========
e_id    rid

160972  906913

160972  906915

160973  906924

160973  2258655

160973  2258656

160973  2258657

160973  2258658

TABLE B
==========
nid     ip_id

160972  906916

160973  2258657

How do i get all the ip_id of table B not present in table A in mysql ? Get the nid of table B whose ip_id is not present in table A.

Expected Result
---------------
nid     ip_id

160972   NULL
i.signori
  • 585
  • 3
  • 16

1 Answers1

0

Using NOT IN

The IN operator allows you to determine if a specified value matches any value in a set of values or returned by a subquery.

SELECT nid, id_id FROM TABLE_B WHERE ip_id NOT IN (SELECT rid FROM TABLE_A)
Roy Bogado
  • 4,299
  • 1
  • 15
  • 31