Home >Backend Development >PHP Tutorial >帮忙写条容易的sql

帮忙写条容易的sql

WBOY
WBOYOriginal
2016-06-13 12:03:35903browse

帮忙写条简单的sql


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

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