0

I`m new in SQL and now straggling with an error 1054 Unknown column in 'where clause' in MySQL.

  1. There`s a simple table 'customer_orders' with 3 columns 'order_id', 'staff_id' and 'order_total'
  2. I needed to insert a line. My query was INSERT INTO customer_orders VALUES (25,1,10.50);
  3. First that worked, then I realized a need to delete the row and insert with a slight change
  4. Now it throws the error 'Error Code: 1054. Unknown column 'order_id' in 'where clause'' Theres 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.

2
  • 1
    How did this work without VALUES? INSERT INTO customer_orders (25,1,10.50); Commented Feb 19, 2022 at 20:30
  • Where did you use the "WHERE" clause...no pun intended. Commented Feb 20, 2022 at 18:34

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.