How to collate hyphens with spaces?
Posted by: Guy Gordon
Date: June 12, 2007 04:01PM

I'm working with a table of old magazines in English. The magazine names often include hyphens (e.g. Readers-Choice Library). But usage of the hyphen is inconsistent and mostly irrelevant.

I want to keep the hyphen in the name, but treat it as a space when searching and sorting. For example, if I display a list of magazines sorted by name, I don't want 'Action-Packed Adventures' to come at the end of the list, well after 'Action Packed Westerns'.

Searching is not so much of a problem, as I can manipulate the user input before searching the table. But I'd really like MySQL to the sorting for me, my way. In the old days I'd create another field containing the names capitalized and with hyphens converted to spaces, and sort an that field. Quite wasteful.

Surely Collation can save my as^H^H^H solve my problem. But the MySQL manual did not suggest any. (I was hoping I could just specify COLLATE=latin-1-something-ci) where 'something-ci' would treat hypen like a space.

Can I create a custom collation from an existing one? Is there some trick I don't know about? "Inquiring minds want to know?"

Options: ReplyQuote


Subject
Views
Written By
Posted
How to collate hyphens with spaces?
3141
June 12, 2007 04:01PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.