This is a discussion on Multiple Trims within the MySQL Database forums, part of the Database Forums category; Given a database with names like "Joe Bob" and "Fred Allen Jr.", the following correctly sorts ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Given a database with names like "Joe Bob" and "Fred Allen Jr.", the
following correctly sorts them: ORDER BY SUBSTRING_INDEX(TRIM(TRAILING ' Jr.' FROM $table.$key),' ',-1) However, I can't come up with a proper way to trim multiple possible suffixes (e.g., Jr., Sr., II, or III). I can't seem to use |s and nesting the trims didn't seem to work either. Ideas? |
![]() |
| Thread Tools | |
| Display Modes | |
|
|