Home >Backend Development >PHP Tutorial >帮忙写条简单的sql

帮忙写条简单的sql

WBOY
WBOYOriginal
2016-06-23 13:52:57786browse



a表 b表 c表  ,a表和b表条件关联gid ,b表和c表关联cid,我要怎么把这3个表联表呀?
条件是gid=20


数据库类型:mysql


回复讨论(解决方案)

select * from b left join(a,c) on (a.gid=b.gid and c.cid=b.cid) where b.gid=20

如果不想要可能出现的 NULL,则
select * from a,b,c where a.gid=b.gid and b.cid=c.cid and a,gid=20

你安装一个Navicat,建立一个视图,完全不需要手写了。 直接拖就行。 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn