http://qs321.pair.com?node_id=213167


in reply to MySQL Alphabetical order with DBI

I like UnderMine's idea, but this only works assuming that there's no double last name with a space between them in the database. If, for example, you have a weird name like "John de Clerk", then the "de"-bit would be regarded as a part of the first name.

Even worse, when someone has a name like "Sandra Meier Schenk". With Swiss people, this could very well occur, with "Sandra" being the first name, "Meier" being the woman's maiden, and "Schenk" the last name of her husband. According to Swiss law, this is perfectly possible and these days even quite frequent. (I won't go into the possible weird situations to which that might lead, let your own imagination run wild.... :-)

Now, I don't know what you intend to do with the data once you've extracted it. If it's just about sorting the stuff, then this might do.

If, however, you want to do something more with the data, even if it's at a later stage, then the only way to go is to re-structure your database. This helps you with your immediate problem, and also puts your data in a form which, should a similar need turn up again, makes the problem much easier. To achieve this, apart from doing it by hand (which is hardly ever an option, unless you only have five entries), the afore-mentioned Lingua::EN::NameParse is probably best.

--cs

There are nights when the wolves are silent and only the moon howls. - George Carlin