表中的列存在,但 SQL 给出错误,提示“未知列”
我有一个具有列名称 Status 的表,但是当我运行下面的代码时,它告诉我:
错误:“字段列表”中存在未知列“help_box.status”
代码:
//Unseen
$variis = "Need Help";
$myid = This is the user's id;
$sql = "select car_help.car_id, agent_names.agent_name, help_box.status,
car_help.why_car, car_help.date_time_added, car_help.just_date,
car_help.type, agent_names.agent_id
from car_help LEFT JOIN agent_names on car_help.agent_whois = agent_names.agent_id
where agent_names.system_id = '$myid' and car_help.system_id='$myid'
and added_by <> '$myid' and help_box.status = '$variis'
UNION
select magazine_help.note_id, agent_names.agent_name, help_box.status,
magazine_help.note_name, magazine_help.date_time_added,
magazine_help.just_date, magazine_help.type, agent_names.agent_id
from magazine_help LEFT JOIN agent_names on
magazine_help.agent_id = agent_names.agent_id
where agent_names.system_id='$myid' and
magazine_help.system_id = '$myid' and added_by <> '$myid'
and help_box.status = '$variis'
UNION
select motorcycle_help.rand_id, agent_names.agent_name,
help_box.status, motorcycle_help.rand_name, motorcycle_help.date_time_added,
motorcycle_help.just_date, motorcycle_help.type, agent_names.agent_id
from motorcycle_help LEFT JOIN agent_names ON
motorcycle_help.by_who = agent_names.agent_id
where agent_names.system_id = '$myid' and
motorcycle_help.system_id='$myid' and added_by <> '$myid'
and help_box.status = '$variis'
UNION
select mobile_questions.bal_test_id, agent_names.agent_name,
help_box.status, mobile_questions.bal_why, mobile_questions.date_time_added,
mobile_questions.just_date, mobile_questions.type, agent_names.agent_id
from mobile_questions LEFT JOIN agent_names ON
mobile_questions.agent_who_ordered = agent_names.agent_id
where agent_names.system_id = '$myid' and
mobile_questions.system_id='$myid' and added_by <> '$myid'
and help_box.status = '$variis'
ORDER BY date_time_added DESC LIMIT $startrow, 20";
$result = mysql_query($sql);
$query = mysql_query($sql) or die ("Error: ".mysql_error());
if ($result == "")
{
echo "";
}
echo "";
$rows = mysql_num_rows($result);
if($rows == 0)
{
print("");
}
elseif($rows > 0)
{
while($row = mysql_fetch_array($query))
{
$row1 = $row['row_name'];
print("$row1");
}
}
I have a table that has the column name Status, but when I run this code below it tells me:
Error: Unknown column 'help_box.status' in 'field list'
Code:
//Unseen
$variis = "Need Help";
$myid = This is the user's id;
$sql = "select car_help.car_id, agent_names.agent_name, help_box.status,
car_help.why_car, car_help.date_time_added, car_help.just_date,
car_help.type, agent_names.agent_id
from car_help LEFT JOIN agent_names on car_help.agent_whois = agent_names.agent_id
where agent_names.system_id = '$myid' and car_help.system_id='$myid'
and added_by <> '$myid' and help_box.status = '$variis'
UNION
select magazine_help.note_id, agent_names.agent_name, help_box.status,
magazine_help.note_name, magazine_help.date_time_added,
magazine_help.just_date, magazine_help.type, agent_names.agent_id
from magazine_help LEFT JOIN agent_names on
magazine_help.agent_id = agent_names.agent_id
where agent_names.system_id='$myid' and
magazine_help.system_id = '$myid' and added_by <> '$myid'
and help_box.status = '$variis'
UNION
select motorcycle_help.rand_id, agent_names.agent_name,
help_box.status, motorcycle_help.rand_name, motorcycle_help.date_time_added,
motorcycle_help.just_date, motorcycle_help.type, agent_names.agent_id
from motorcycle_help LEFT JOIN agent_names ON
motorcycle_help.by_who = agent_names.agent_id
where agent_names.system_id = '$myid' and
motorcycle_help.system_id='$myid' and added_by <> '$myid'
and help_box.status = '$variis'
UNION
select mobile_questions.bal_test_id, agent_names.agent_name,
help_box.status, mobile_questions.bal_why, mobile_questions.date_time_added,
mobile_questions.just_date, mobile_questions.type, agent_names.agent_id
from mobile_questions LEFT JOIN agent_names ON
mobile_questions.agent_who_ordered = agent_names.agent_id
where agent_names.system_id = '$myid' and
mobile_questions.system_id='$myid' and added_by <> '$myid'
and help_box.status = '$variis'
ORDER BY date_time_added DESC LIMIT $startrow, 20";
$result = mysql_query($sql);
$query = mysql_query($sql) or die ("Error: ".mysql_error());
if ($result == "")
{
echo "";
}
echo "";
$rows = mysql_num_rows($result);
if($rows == 0)
{
print("");
}
elseif($rows > 0)
{
while($row = mysql_fetch_array($query))
{
$row1 = $row['row_name'];
print("$row1");
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
help_box.status 位于哪个表中?您没有在 FROM 或 JOIN 中引用它,因此它不知道在哪里查找。它试图查找名为 help_box 的表和名为 status 的列。
What table is help_box.status in? You don't reference it in your FROM or your JOIN so it doesn't know where to look. It's trying to find a table named help_box and a column named status.