mysqlsqlsql-updatemysql-select-db

MYSQL - How to UPDATE after SELECT from a table


i want to UPDATE the a column after i SELECT a table

SELECT id_copies, id_shop, id_dvd 
FROM dvd_copies
WHERE id_dvd = '001-192.168.1.103-6' AND id_shop='002'
ORDER BY id_copies DESC
LIMIT 2;

i got just 2 rows that i want to be updated how can i UPDATE these rows?


Solution

  • You can also do the following:

    UPDATE dvd_copies
    SET your_column_to_update ='your value'
    WHERE id_dvd = '001-192.168.1.103-6' AND id_toko='002'
    ORDER BY id_copies DESC
    LIMIT 2