简体   繁体   中英

Mysql update first unique match only

I have a table with multiple occurence of a value (SKU) linked with a certain value for another column (column2). I want to update the value of column2 with the first match of SKU.

Update table set column2 = test where sku = 18.

I have twice the value 18 for sku, but wanna update column2 only on the first occurence of sku = 18.

How

update table set column2 = test where sku = 18 order by id limit 1;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM