首頁  >  文章  >  後端開發  >  php查询mysql多个表字段解决方法

php查询mysql多个表字段解决方法

WBOY
WBOY原創
2016-06-13 13:23:351066瀏覽

php查询mysql多个表字段

SQL code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->SELECT id,channel,title FROM teble1 WHERE id='$id'

我想在查询中添加查询表table2,查询字段为:name,tel应该怎么写?

------解决方案--------------------
逗号为英文状态:
SQL code

SELECT t1.id,channel,title,t2.name,t2.tel FROM teble1 as t1, table2 as t2 WHERE t1.id='$id'
<br><font color="#e78608">------解决方案--------------------</font><br>
探讨

逗号为英文状态:
SQL code

SELECT t1.id,channel,title,t2.name,t2.tel FROM teble1 as t1, table2 as t2 WHERE t1.id='$id'
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn