Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: MySQL Alphabetical order with DBI

by earthboundmisfit (Chaplain)
on Nov 15, 2002 at 13:56 UTC ( #213151=note: print w/replies, xml ) Need Help??

in reply to MySQL Alphabetical order with DBI

You could do that, splitting on the space in the name column and then running a sort in Perl, but it's going to lead to all sorts of problems if/when variant names crop up. What happens if you have a name like John Jacob Ezekiel Smith.....?

Personally, I would restructure the database and split the column into consituents. FirstName (varchar 50), LastName (varchar 50), pageref (??). That way, you can use SQL to perform the sort (e.g. SELECT * FROM authors ORDER BY LastName) and eliminate the possibility of sorting on the wrong name. You would also see a speed performance increase doing it this way.

update: a little slow on the keyboard this morning. Asim makes a good point about Lingua::EN::NameParse

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://213151]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2022-08-17 19:03 GMT
Find Nodes?
    Voting Booth?

    No recent polls found