Jump to content

sql order ?


drisate

Recommended Posts

Hey guys ... how do you order a table by title asc when the first character are special characters like é or ê html encoded ?

 

Once encoded they look like this :

é and ê

So when i try to sort them MySQL see's the & and places them at the begining ... How can i do this ?

Link to comment
Share on other sites

I'm definitely not a professional programmer (yet ;D). But you have asked a fairly difficult question... In my opinion, I think it'd be fine to get all the results and translate them to real characters and then sort them in an array... Tons of ways of doing THAT. But it sounds like a good method to me! If anyone's got a better idea, please suggest :S.

Link to comment
Share on other sites

Yeah thats what i thought too ... but i was hopping for a magique function that would encode the col directly in the SQL line ... :-(

 

something like

 

SELECT * FROM lexique WHERE ( titre like 'Â%' or titre like 'À%' or titre like 'â%' or titre like 'à%' or LOWER(titre) like 'a%' ) order by html_entity_decode(titre) asc limit 0, 15

Link to comment
Share on other sites

I'm no expert either, but I don't think it will be possible. Personally I'd have thought the only way to successfully achieve the order would be to store the actual character in the database, not the html encode. Depending on the amount of records you could probably fetch the data then write a custom sort with PHP, or sort it after substituting the values, but if your doing that you may aswell store them in the db.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.