I want to create a new column in a MYSQL table that has Fn Ln instead of Ln, Fn. Most of my data is printed Fn Ln.
Another idea is to incorporate a string function each time there is an output (php based) but that seems to waste resources. Finally, I couldn’t find the syntax (loop or foreach) for my php function anyway.
Here is the working php function that I got from a previous post:
$name = "Lastname, Firstname";
$names = explode(", ", $name);
$name = $names[1] . " " . $names[0];
You can use the mysql function SUBSTRING_INDEX to get a portion of a string up to an specified number or occurrences.
Make sure to change anything I’ve prefixed with a $ to what you want it called
That splits the name field on , and puts the second part first, in the new field you created.