简体   繁体   中英

Error Code: 1052 when INSERTing (ID in field list is ambiguous)

I am being thrown a really weird error code, judging that I have successfully INSERTed values using the same query in a similar schema.

I am trying to execute the following query:

INSERT INTO part_approval (part_quote_key)
SELECT part_quote_key
FROM database.part_quote;

The part_approval table is empty and columns are either NULLable or have DEFAULT values. The part_quote table looks like this:

part_quote_key  price      batch       part_key   quote_key
1               12.90      30          5          17        2014-06-03 15:53:18
2               22.87      15          8          17        2014-06-03 16:14:52
3               19.96      15          9          17        2014-06-03 15:53:18
4               24.52      15          10         17        2014-06-03 15:53:18
5               13.65      15          14         17        2014-06-03 16:14:52

The error details point to "Column part_key is ambiguous in field list". However, the part_key column is not even in my result list of the above SELECT statement.

In addition, I've used the following statement to populate a similar table and it worked:

INSERT INTO component_approval (component_quote_key)
SELECT component_quote_key
FROM database.component_quote;

Is there anything I am overlooking?

Thanks for all your help in advance, Marius

Please try running your query by qualifying the columns by prefixing the table name or alias.

Refer this simmilar question: 1052: Column 'id' in field list is ambiguous

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM