Home > Backend Development > PHP Tutorial > mysql联合查询二张表的数据

mysql联合查询二张表的数据

WBOY
Release: 2016-06-13 11:11:30
Original
1035 people have browsed it

mysql联合查询2张表的数据
有2张表 tb_a   tb_b(2表关系是a.id=b.tid)  怎么实现用一条sql语句查到页面的数据呢  把学院查出来还有学院下面的老师  表字段的是自己随意写
页面首页接受到一个学院的id  然后查询。。求一条sql能查出页面所需数据


------解决方案--------------------
select * from tb_a a,  tb_b b where a.id=b.tid
------解决方案--------------------
你的tb_a,tb_b都代表什么?楼主没有说清楚
------解决方案--------------------
二楼正解啊 。
------解决方案--------------------
表大不大?不大的话,可以用联表,大的话,先抽取一张表,在自己实现逻辑抽取第二张
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