php多表聯檢?

來源:互聯網
上載者:User
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 小明 男
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.