The most common MySQL queries are listed in this document. These are the queries that I use mostly and they are my reference when I am writing queries. These are all the queries that you need to know for your MySQL database applications.
Append a Value in a String Column
UPDATE quotes SET tags = CONCAT(col_name,' and append this') WHERE category = 1;
If Column is Null
If the field code is NULL by default you need to use:
UPDATE table_name SET col = CONCAT(IFNULL(col_name,''), 'and append this') WHERE id = 1;
Otherwise the concat will always result in NULL.
Replace a String in a string field
SET col = REPLACE(col, 'match', 'replace')
UPDATE articles SET tags = REPLACE(tags, "Top", 'Top 10')
This query only replaces the text that matches, so if the string and more than the matched text, the rest of the unmatched text remains intact and is not lost.
Table of contents