Home > database > The exists multi-table query problem
The exists multi-table query problem
Time:10-09
Bosses, I associated database table A and table B through uid, I want to through the exists now, at the same time query A id, B the name field, could you tell me how to write the SQL can be...
The select Anderson d //, b.n ame - how to write here... The from tableA a WHERE the EXISTS ( SELECT the name FROM tableB b WHERE b.u id=a.u id)
CodePudding user response:
If you want to take B table fields, or use the JOIN syntax The SELECT Anderson D, B.N AME The FROM tableA A The JOIN tableB B ON A.u id=B.u id
CodePudding user response:
The select Anderson d, b.n ame from a, b where a.u id=b.u id
CodePudding user response:
Exists is used to judge, the value of the inside should be can't get, for example the exists inside the select the name and select 1 no difference