SQL新手求助:事务执行报1054错误(WHERE子句未知列AX12)
Hey there! I see you're new to SQL and ran into a common rookie mistake—no worries, we'll get this sorted quickly.
What's causing the error?
The problem is in your WHERE clause: partID = AX12. Since partID is almost certainly a string/text column, the value AX12 needs to be wrapped in single quotes (or double quotes, depending on your SQL mode). Right now, MySQL is interpreting AX12 as the name of a column, and since your hsitems table doesn't have a column named AX12, it throws that 1054 error.
Corrected Transaction Code
Here's the fixed version of your SQL statement:
START TRANSACTION; UPDATE hsitems SET price = price * 2 WHERE partID = 'AX12'; COMMIT;
Quick Tip for Future Queries
Any time you're filtering on a string-based column (like part IDs, names, emails), always enclose the value in single quotes. This tells the database you're referring to a literal string value, not a column name.
内容的提问来源于stack exchange,提问作者Mark Pedigo

