下面定义3个表A,B,C,字段分别为A:a,b;B:b,c;C:c,d
正常where 使用语句如下:
select A.a,B.b,C.c from A
inner join B on A.b=B.b
inner join C on C.c=B.c
where A.a=10 or B.b=10 or C.c=10
下面的SQL 嵌入到inner 中的使用方式:
select A.a,B.b,C.c from A
inner join B on A.b=B.b and B.b=10
inner join C on C.c=B.c and C.c=10
使用UNION联合两个语句即可:select * from a where cid=1
UNION
select * from b where cid=1
select * from subject a join attachment b on a.tid=b.tidjoin message c on b.tid=c.tid
或者
select * from subject a ,attachment b ,message c
where a.tid=b.tid and b.tid=c.tid
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)