'Unknown column in 'where clause' while there`s no 'where clause' and the column isn`t mentioned in the query
I`m new in SQL and now straggling with an error 1054 Unknown column in 'where clause' in MySQL.
- There`s a simple table 'customer_orders' with 3 columns 'order_id', 'staff_id' and 'order_total'
- I needed to insert a line. My query was INSERT INTO customer_orders VALUES (25,1,10.50);
- First that worked, then I realized a need to delete the row and insert with a slight change
- Now it throws the error 'Error Code: 1054. Unknown column 'order_id' in 'where clause''
There
s no such column in the query and the column isnt mentioned. I renamed the column into 'order_id_new' and explicitly specified the column names in the INSERT statement - the same error.
INSERT INTO customer_orders (order_id_new, staff_id, order_total) VALUES (23,1,11.43);
When I created a copy of the table the same worked fine.
Any ideas what is wrong with the table?
Thanks in advance.
Solution 1:[1]
It turned out there was a Trigger which conflicted with the query. Strange that the error doesn`t refer to the trigger in any way. Once I fixed the trigger the query worked.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Koteyko |
