INNER JOIN语句中的歧义列 [英] Ambiguous column in INNER JOIN statement
问题描述
我对此感到困惑.我已经搜索过互联网,但仍然让我感到困惑.我有以下表格:
I am getting confused with this. I have searched the internet and it is still confusing me. I have the following tables:
会议:meeting_id
,title
,chairman
,secretary
,occurances
房间:room_id
,room
,date
,time
,meeting_id
Meetings: meeting_id
, title
, chairman
, secretary
, occurances
Rooms: room_id
, room
, date
, time
, meeting_id
我希望所有内容都显示在桌子上.我的PHP如下:
I want everything to be displayed on a table. My PHP is as follows:
<?php
$result = mysql_query("SELECT * FROM Meetings INNER JOIN Rooms ON meeting_id = Rooms.meeting_id")
or die(mysql_error()); ;
if (mysql_num_rows($result) == 0) {
echo 'There Arent Any Meetings Setup Yet';
} else {
echo "<table border='0'><table border width=100%><tr><th>Title</th><th>Chairperson</th><th>Secretary</th><th>Terms of Reference</th><th>Occurances</th><th>Room</th><th>Date</th><th>Time</th>";
while($info = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td><br/>" . $info['title']." </td>";
echo "<td><br/>" . $info['chairperson']. "</td>";
echo "<td><br/>" . $info['secretary']."</td>";
echo "<td><br/>" . $info['tof']. "</td>";
echo "<td><br/>" . $info['occurances']. "</td>";
echo "<td><br/>" . $info['room']. "</td>";
echo "<td><br/>" . $info['date']. "</td>";
echo "<td><br/>" . $info['time']. "</td>";
}
}
echo "</tr>";
echo "</table>";
?>
它带有以下错误消息:
on子句中的'meeting_id'列不明确
Column 'meeting_id' in on clause is ambiguous
我试图显示会议表中的所有字段,并且显然只显示会议室,日期和时间.
I am trying to display all the fields from the meetings table and obviously the room, date and time only.
我该如何解决?
推荐答案
您需要定义要从中选择meeting_id
的表.
You need to define which table you want meeting_id
to be selected from.
例如
`SELECT * FROM Meetings INNER JOIN Rooms ON Meetings.meeting_id = Rooms.meeting_id`
这篇关于INNER JOIN语句中的歧义列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!