Heim  >  Artikel  >  Backend-Entwicklung  >  php多表联检?

php多表联检?

WBOY
WBOYOriginal
2016-06-13 13:01:54785Durchsuche

php多表联查??
我有2个表
A表:                 B表:
id   title          id     content
1     a1            a1      内容1
2     a2            a2      内容2
3     a3            a3      内容3

现在我需要根据A表里的title显示3条B表里的content,   也就是大家常说的把分类和内容分表放, 但是取得时候怎么根据A表里的title取得B表的内容。

我要显示3条A表title 但是还要对应B表的content, 分表从来没了解过,  这次大家就来教育教育我吧
------最佳解决方案--------------------
本帖最后由 xuzuning 于 2012-11-09 08:48:42 编辑 select a.id, a.title, b.content from A表 a, B表 b where a.id=b.id limit 3
------其他解决方案--------------------
select A.id, A.title, B.content from A inner join B b on A.title=B.id 
------其他解决方案--------------------
网上很多例子
------其他解决方案--------------------
left join in
------其他解决方案--------------------

回复楼上朋友们:
……


刚醒来, 就来看帖子, 试了下版主和jordan102的方法  只能得到A表的东西,  或许是我没用对,  还请麻烦你们写出那一小段代码 就是写到while循环显示的地方。  我再补充下我的问题吧, 没描述好

A表:                  
------其他解决方案--------------------
    B表:
id   title    sex     
------其他解决方案--------------------
    id     content    age   ……
1     小易     男      
------其他解决方案--------------------
    小明     学生       18    ……
2     小明     男      
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn