Home > Backend Development > PHP Tutorial > 这个sql怎么写?

这个sql怎么写?

WBOY
Release: 2016-06-23 13:46:13
Original
986 people have browsed it


这个sql怎么写?


回复讨论(解决方案)

select * from A left join B on A.id=B.id;

select * from A,B where A.id=B.id
Copy after login

SELECT A.id AS `aid` , A.name AS aname , B.p_id AS pid , B.id AS bid , B.session AS bsession FROM A,B WHERE A.aid=B.bid

select * from A left join B on A.id=B.id;


要从b表中找出符合session字段的
如果加上where b.session ='aaa
加这个条件的话a表中没有session字段,就光能列出b表的数据

selact * from a left join (select * from b where session='aaa') t on a.id=t.id

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template