我有一个mysql查询,它试图加入表格,将两个表格中的数据显示在网页上的一个表格上?
<?php
include 'library/connect.php';
$result = mysql_query("SELECT * FROM meetings INNER JOIN rooms USING ('room', 'date', 'time' ) ");
echo "<table border='1'><tr><th>Title</th><th>Chairman</th><th>Secretary</th><th>Terms of Reference</th><th>Named membership</th><th>Occurences</th><th>Room</th><th>Date</th><th>Time</th></tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['title']. "</td>";
echo "<td>" . $row['chairman']. "</td>";
echo "<td>" . $row['secretary']. "</td>";
echo "<td>" . $row['termsOfReference']. "</td>";
echo "<td>" . $row['occurences']. "</td>";
echo "<td>" . $row['room']. "</td>";
echo "<td>" . $row['date']. "</td>";
echo "<td>" . $row['time']. "</td>";
echo "</tr>";
}
echo "</table>";
include 'library/closedb.php';
?>
我是否需要某个表ID?
答案 0 :(得分:2)
我怀疑date
和time
是rooms
表中的列,所以它们不应该是JOIN条件的一部分。尝试:
SELECT *
FROM meetings m
INNER JOIN rooms r
ON m.room = r.room