Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: MySQL Alphabetical order with DBI

by earthboundmisfit (Chaplain)
on Nov 15, 2002 at 13:56 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-03-28 17:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found