我有 3 张桌子:
tb_wrapper tb_doc tb_aut
===================== ==================== =======================
|id|web|title|source| |id| web | content | |id|web|aut | linkAut|
===================== ==================== =======================
|1 | A | AA | AAA | |1 | A | AAAA | |1 | A | B | C |
===================== ==================== |2 | A | D | E |
=======================
我想从具有相同的 3 个表中获取所有记录数据web
。
这是我的代码:
$query = mysql_query("
SELECT
tb_wrapper.web,
tb_wrapper.title,
tb_wrapper.source,
tb_doc.web,
tb_doc.content,
tb_aut.web,
tb_aut.aut,
tb_aut.linkAut
FROM
tb_doc
INNER JOIN tb_wrapper ON tb_doc.web = tb_wrapper.web
AND
INNER JOIN tb_aut ON tb_doc.web = tb_aut.web
");
错误问题:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\AppServ\www\sukses\indexsummary.php on line 87
。
编辑
然后我想把它们全部打印出来:
while ($row = mysql_fetch_array($query)) {
$source = $row['source'];
$title = $row['title'];
$content = $row['content'];
$aut = $row['aut'];
$linkAut = $row['linkAut'];
echo '<h2><a href='.$source.'> '.$title.' </a></h2>';
echo '<p><a href='.$aut_url.'> '.$aut.' </a></p>';
}
结果,它们被打印了两次。AA B 和 AA D。如何使它们成为 AA BD ?
请帮我。提前致谢 :)