Forum Moderators: open
Using PHP I could select all records, explode the field at "\r\n" and then update the field with the first array value. Is there any native MySQL function that would allow me to do it more simply?
UPDATE table SET field=LEFT(field,INSTR(field, '\r\n')-1)
You may have to play with the newline characters to get this to work.
Familiarity with MySql String functions is a good thing to have:
[dev.mysql.com...]
Edit: Of course, this may fail if the string does not actually contain more than one line... a CASE construct should be able to take care of that easily enough.
[dev.mysql.com...]
[edited by: FalseDawn at 4:52 pm (utc) on May 26, 2007]