Mysql - 多表查询

member 表: uuid, username.
people 表: uuid, name.

查询俩表中 uuid = u01 的 username, name。

SELECT member.username, people.name
FROM  member 
LEFT JOIN people ON member.uuid = people.uuid WHERE member.uuid = u01

peopel 表: uuid,name.
company 表: uuid,companyid,name.
app 表: uuid,companyid,name,check.

查询仨表中的 people.name, company.name, app.name 且 app.check = 0

SELECT app.name AS aname, people.name AS pname, company.name AS cname
FROM ( app LEFT JOIN people ON app.uuid = people.uuid )
LEFT JOIN company ON app.companyid = company.companyid
WHERE ( app.checked = 0 )
返回文章列表 文章二维码 打赏
本页链接的二维码
打赏二维码
期待你的评论

1 条评论
  1. hawkhost 青铜   hawkhost  

    现在学access了,毕竟excel用的多!