mysql查询语句

二胖二胖 发布于 2017/08/28 11:49
阅读 113
收藏 0

我要查询多张关联表的信息不知道哪里有错,下面是代码:select b.*,pat.*,per.*,pese.*,gro.* from bedtable b left join patient pat on b.pat_id = pat.id left join personalinformation per on pat.per_id = per.id left join personalservice pese on pat.id = pese.pat_id left join group gro on pese.gro_id = gro.id where b.pat_id is not null;

加载中
0
Asdybing
Asdybing

是什么错误啊,sql错误还是查询结果错误,你得说清楚啊

0
贲大侠
贲大侠

SELECT
    b.*, pat.*, per.*, pese.*, gro.*
FROM
    bedtable b
LEFT JOIN patient pat ON b.pat_id = pat.id
LEFT JOIN personalinformation per ON pat.per_id = per.id
LEFT JOIN personalservice pese ON pat.id = pese.pat_id
LEFT JOIN GROUP gro ON pese.gro_id = gro.id
WHERE
    b.pat_id IS NOT nul

二胖二胖
二胖二胖
恩,就是那里,group是关键字
0
mlovewt
mlovewt
字段重复
返回顶部
顶部