I have a column that has a name. The names are currently listed "lastname, firstname" When it is a person. Sometimes it is listed "companyname, The" But other times the company is listed correctly. Is there a way to do a search an replace in Sql that says "where a comma is present reverse the stuff before the comma with the stuff after the comma"? I am presently doing it author by author by UPDATE data SET author = replace(author, "Luts, Frank", "Frank Luts"); PHP: But this is getting old Thanks
I am not that great at MySQL, I am better at standard SQL, but try the following command... The first part should select the Name (LastName, FirstName) and switch it to (FirstName LastName): SELECT CONCAT(SUBSTRING_INDEX(author, ',', -1), ' ', SUBSTRING_INDEX(author, ',', 1)) FROM data Before I go any further though I want to make sure this works. Try it out and let me know. Then we can worry about updating the records. Tim