Reputation: 151
I'm quite confused with this problem.
I have a table of purchase_list
that about like this:
purchase_code item unit order_amount recived_amount price
TRX-000001 1 1 0 85 14200
Then i try to update that record with this query:
UPDATE `purchase_list`
SET `order_amount`='85'
WHERE `purchase_code`='TRX-000001' AND `item`='1' AND `unit`='1'
And end up with error:
#1054 - Unknown column 'unit' in 'where clause'
But when i do SELECT
query:
SELECT `order_amount`
FROM `purchase_list`
WHERE `purchase_code`='TRX-000001' AND `item`='1' AND `unit`='1'
it does show result:
order_amount
0
And when I click phpmyadmin's Simulate query
button, it does says:
Matched rows: 1
but still it can't execute the update query. Any idea how to solve my problem?
Upvotes: 1
Views: 2783
Reputation: 1929
Sometimes this error occurs due to the use of same quotes (single ' or double ") for column name and value. For example, in my case: I used these two queries
Query #1:
UPDATE 'customerinvoice'
SET 'invoice_status' = 2
WHERE 'invoice_no' = '20200907202602_6'
Query #2:
'UPDATE customerinvoice
SET invoice_status = 2
WHERE invoice_no = 20200907202602_6'
and it throws this error.
(1054, "Unknown column '20200907202602_6' in 'where clause'")
I solved this issue using:
Query #1
UPDATE 'customerinvoice'
SET 'invoice_status' = 2
WHERE 'invoice_no' = "20200907202602_6"
Query #2:
'UPDATE customerinvoice
SET invoice_status = 2
WHERE invoice_no = "20200907202602_6" '
Note: I am working in python and database is MySQL.
Upvotes: 0
Reputation: 1270583
The most likely cause of your problem is a trigger on purchase_list
. You should check if that is the case.
A secondary possibility is that the two queries are pointing to different databases with different table structures.
Upvotes: 0
Reputation: 1399
Check datatype of unit
column and try with
AND `unit`=1
If data type of unit
is int else share table structure of `purchase_list.
Upvotes: 2