我有 3 张桌子:
tb_document
============================
|document_id|document_title|
============================
| 1 | A |
| 2 | B |
| 3 | C |
============================
tb_wrapper_scho tb_wrapper_li
============================= =============================
|id_scho|data_title|doc_name| |id_sli |data_title|doc_name|
============================= =============================
| 1 | TitleA | A | | 1 | TitleB | B |
| 2 | TitleC | C | =============================
=============================
我想data_title
从一个tb_wrapper_scho
结果中tb_wrapper_li
得到相同doc_name
的结果document_title
tb_document
$title
这是查询:
SELECT
tb_document.document_title,
tb_wrapper_scho.data_title,
tb_wrapper_scho.doc_name,
tb_wrapper_li.data_title,
tb_wrapper_li.doc_name
FROM
INNER JOIN tb_wrapper_scho ON tb_document.document_title = tb_wrapper_scho.doc_name
INNER JOIN tb_wrapper_li ON tb_document.document_title = tb_wrapper_li.doc_name
WHERE
document_id = '$doc_id'
while ($row = mysql_fetch_array($sql)) {
$title = $row['data_title'];
print_r($title);
}
它给了我空白的结果。请帮帮我..谢谢:)