我有一個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的地方嗎?
什麼問題?如果按原樣運行查詢,你會得到結果嗎? – 2012-01-04 19:07:07
'USING'不是正確的語法。它應該是「ON」和比較條款。 – 2012-01-04 19:07:40
@JeremyHolovacs:MySQL支持USING join語法。有關詳細信息,請參見[JOIN文檔](http://dev.mysql.com/doc/refman/5.0/en/join.html)。 – 2012-01-04 19:08:12