I have a TEXT column in MySQL table. Lines of text are appended to the end of the field, with UPDATE query and CONCAT function. Every line ends with \r\n.
single record field content:
---------------------------
line1
some other line
last line
UPDATE tbl SET field = CONCAT(field, 'last line\r\n')
Sometimes there is a need to replace the last line with a different string. How can I do it using MySQL UPDATE query and string function(s)?
EDIT
To make it simpler I could store the lines count and increment it every time the new line is inserted.
Try this: