SQL: SELECT * FROM [Table]postitems LEFT JOIN [Table]postmessages USING (itemid) WHERE itemid='23'
Error: Column: 'itemid' in where clause is ambiguous
Errno.: 1052
$query = $_SGLOBAL['db']->query('SELECT * FROM '.tname('spaceitems').' LEFT JOIN '.tname('spacenews')." USING (itemid) WHERE itemid='$itemid'");
} else {
$query = $_SGLOBAL['db']->query('SELECT * FROM '.tname('postitems').' LEFT JOIN '.tname('postmessages')." USING (itemid) WHERE itemid='$itemid'");
}
复制代码
将其替换为:
if($do == 'pass') {
$query = $_SGLOBAL['db']->query('SELECT * FROM '.tname('spaceitems').' i LEFT JOIN '.tname('spacenews')." n USING (itemid) WHERE i.itemid='$itemid'");
} else {
$query = $_SGLOBAL['db']->query('SELECT * FROM '.tname('postitems').' i LEFT JOIN '.tname('postmessages')." m USING (itemid) WHERE i.itemid='$itemid'");