[英]Error in query (1052): Column 'register_log_id' in field list is ambiguous
The POS software I use has recently updated and split the info I need to download into 2 tables. 我使用的POS软件最近更新了并将需要下载的信息分成2个表格。 I thought I had the issue sorted but I'm getting the error in the title.
我以为我已经解决了问题,但是标题出现错误。 Here is the code:
这是代码:
SELECT register_log_id, p.register_id, p.employee_id_open,
p.employee_id_close, p.shift_start, p.shift_end, s.open_amount,
s.close_amount, s.payment_sales_amount, s.total_payment_additions,
s.total_payment_subtractions, p.notes
FROM phppos_register_log p JOIN
phppos_register_log_payments s
ON p.register_log_id = s.register_log_id
WHERE shift_end <> '0000-00-00 00:00:00' AND register_log_id > 2607
In the WHERE
clause you need to add the alias to register_log_id
so MySQL knows which table you are trying to limit it by. 在
WHERE
子句中,您需要将别名添加到register_log_id
以便MySQL知道您要限制它的表。
So either: 所以:
WHERE shift_end <> '0000-00-00 00:00:00' AND p.register_log_id > 2607
or 要么
WHERE shift_end <> '0000-00-00 00:00:00' AND s.register_log_id > 2607
You don't have the issue with shift_end
because it must only be in one of the tables. 您没有
shift_end
的问题,因为它只能在表之一中。
Column 'register_log_id' in field list is ambiguous
字段列表中的列“ register_log_id”不明确
This simply means register_log_id
is not an unique column name and exists in more than one table you are referencing in your query. 这仅表示
register_log_id
不是唯一的列名,并且存在于您在查询中引用的多个表中。 Simply prefix that field with table name and you are done. 只需为该字段加上表名作为前缀即可完成。
Column
register_log_id
in field list is ambiguous字段列表中的
register_log_id
列不明确
That means that the column: register_log_id
appears in more than one table. 这意味着列
register_log_id
出现在多个表中。 Simply fully qualify it as: tableName.tableColumn
只需将其完全限定为:
tableName.tableColumn
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.