I have an ATM card database in which there are account_no, card_no, is_blocked, is_activated, issue_date fields. The field account number and card numbers are not unique as the obsolete card expires and is marked as is_block = Y and another record with such same card number, the account number will be inserted in a new line with is_blocked = N. Now I need to update is_blocked / is_activated using issue_date ie
UPDATE card_info set is_blocked='Y' where card_no='6396163270002509' AND opening_date=(SELECT MAX(opening_date) FROM card_info WHERE card_no='6396163270002509')
but this does not allow me to do this, it gives the following error
1093 - You can't specify target table 'card_info' for update in FROM clause
source share