Home > database >  For a written associated SQL?
For a written associated SQL?

Time:09-20






More than two tables, respectively, A, B

Want to find A table in the records of all authorid is 8, and column in each record results, the correlation data shown in the table B

Select ` a `. ` id ` ` a ` ` sourcename `, ` a ` ` authorid `, b.i d AS b__id, b.u id AS b__uid, biggest id AS b__cid from ` ts_wffiles ` a LEFT JOIN ` ts_checkin ` b on Anderson, d=biggest id where a.a uthorid=8 GROUP BY id order BY id desc

The results are:


I want to get as a result of the record in red box should be on the records in a red box in the figure, also is the record of take out the ID in the table of 10 B, take out here is that the ID for 9
But if I behind the WHERE to connect A and b.u id=8, but the left join A table record filtering to take out, I want to keep all the records in A table at the same time to meet the uid=8 records in the table B,


For writing SQL

CodePudding user response:

According to your meaning should be LEFT JOIN ` ts_checkin ` b on Anderson, d=biggest id and b.u id=8
  • Related