Bruce Bruce - 6 months ago 23
SQL Question

Mysql subtraction with 2 table or php

I have 2 table(example A and B)

A

-----------
id | name
-----------
1 | Bruce

2 | Peter

3 | Jack

4 | Alin


B

---------------------
id | status | A_id
---------------------
1 | 0 | 1

2 | 0 | 3


Subtraction with 2 table or php , I want to result is C

C

------------
id | name
------------
2 | Peter
4 | Alin


How can I do it?

Answer

Please give a try. Your C is a records that not shown from B right?

SELECT * From table a where id NOT IN (SELECT a_id from B)