Dùng LIKE với wildcard % để tìm và cập nhật hàng kết thúc bằng chuỗi con.
Cú pháp:
UPDATE yourTableName SET yourColumnName='yourValue' WHERE yourColumnName LIKE '%.yourString';
Demo: Bảng RowEndsWithSpecificString cột FileName.
Dữ liệu: MergeSort.c, BubbleSortIntroduction.pdf, AllMySQLQuery.docx, JavaCollections.pdf, JavaServlet.pdf
Cập nhật file .docx thành .pdf:
mysql> update RowEndsWithSpecificString -> set FileName='IntroductionToCoreJava.pdf' -> where FileName LIKE '%.docx'; Query OK, 1 row affected (0.14 sec)
Kết quả: AllMySQLQuery.docx → IntroductionToCoreJava.pdf