How do I write SQL statements when I search for records in Table A that have no data in Table B? For example, a_id & nbsp; name & nbsp; & nbsp ;........ & nbsp; 1 & nbsp; how do I write SQL statements for records in Table B without data in table?
For example:
Table
A_id name ........
1 Zhang San
2 Li Si
3. Wang Wu
4 Zhao Liu
Table B
B _id a_id total
1 100
2 3 200
How can I find Li Si and Zhao Liu after I select the overdue payment submission option above ????
------ Solution --------------------
Because Wang Wu has made a payment and has not yet owed a loan, he does not need to submit a ticket.
The primary account should be used to find out the accounts that have not been handed in or have overdue payments.
Select t1.name from a as t1 left join B as t2 on t1.a _ id = t2.a _ id where qianfei is null or qianfei> 0;
You can perform this operation by left join first, and then find the records with qianfei> 0 or qianfei being null.