I need to update the records of some tables, and I tried using the following command:
UPDATE auction a
JOIN (SELECT bidding_price, user_id, auction_id FROM bid_account WHERE auction_id = a.auctionID ORDER BY bidpack_buy_date DESC LIMIT 1) ult_lance_a
SET a.auc_final_price=ult_lance_a.bidding_price, a.buy_user=ult_lance_a.user_id
WHERE a.auctionID=ult_lance_a.auction_id;
However I am getting the following error:
#1054 - Column 'a.auctionID' unknown in 'where clause'
what did I do wrong?
Here is the return of the command: SELECT bidding_price, user_id, auction_id FROM bid_account WHERE auction_id = XXX ORDER BY bidpack_buy_date DESC LIMIT 1
bidding_price = 6.23
user_id = 1720
auction_id = 1818
In the auction table, there are the columns:
auc_final_price
bidding_price
auctionID
There are several records, but the records are the same for the columns: auction_id and auctionID.
What I need is to just grab the LAST value entered in the bid_account table, and copy the values to the auction table.
auction_idexists in bothauctionandbid_account?auctiontable by inserting the values values obtained in the JOIN, which are in thebid_accounttable.auctionID and auction_id