简体   繁体   English

查询错误(1052):字段列表中的列'register_log_id'不明确

[英]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.

相关问题 #1052-在英里半径查询中,字段列表中的“纬度”列含糊不清,无法弄清原因 - #1052 - Column 'lat' in field list is ambiguous in a mile radius query, can't figure out why MySQL错误#1052 from子句中的列不明确 - MySQL Error #1052 Column in from clause is ambiguous Laravel 6 错误:SQLSTATE[23000]:违反完整性约束:1052 where 子句中的列“id_perusahaan”不明确 - Laravel 6 Error : SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id_perusahaan' in where clause is ambiguous Laravel SQL 错误:违反完整性约束:1052 where 子句中的列“id”不明确 - Laravel SQL Error: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous 错误:字段列表中的列“ id”不明确php mysqli - Error: Column 'id' in field list is ambiguous php mysqli 完整性约束违规:1052 where子句中的列&#39;id&#39;不明确 - Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous Laravel 完整性约束违规:1052 列 'id' in where 子句不明确 - Laravel Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous 字段列表中的列“ media_id”不明确 - Column 'media_id' in field list is ambiguous 字段列表中的列“ student_id”不明确 - Column 'student_id' in field list is ambiguous 使用 Eloquent 时字段列表中的列“id”不明确 - Column 'id' in field list is ambiguous using Eloquent
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM