strange problem with sort!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

strange problem with sort!

Post by pelegk2 »

i am doing this :

Code: Select all

SELECT * from clients  order by  client_name asc
and for some reason i dont get the result sorted!!!!!
why is that?thanks in advance
peleg
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Post by Dr Evil »

Are you sure you don't have spaces before some of your names or other hidden characters ?

Dr Evil
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

what data type is the client_name field?

Mark
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

its varcahr(30) and ichecked no spaces!
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Everything looks fine unless your mis-spelling the field or table name. Just try playing with it a bit:

SELECT * FROM clients ORDER BY client_name ASC
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

maybe the problem its hebrew letters?
right to left language?
but still strange in other places works just find
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

ASC is the default order anyway, so you don't need to specify it. As a test, if you sort by DESC instead, are the results in a different order than if you omit the order? (just to prove it's at least doing some sort of ordering :o)
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

nope it gives not the correct order opposite
but an oposite order to the regular order i recive at the moment
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Must be down to the hebrew characters then, you could try starting mysql with the --default-character-set=hebrew option to see if it makes any difference, though i'm not sure if that is your default character set or just for this particular instance, but worth a go as a test.

http://www.mysql.com/doc/en/Character_sets.html is worth a read too.
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

where execlly do i do :
"default-character-set=hebrew "
in which ini file do i define it?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Windows or *nix ?
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

windows
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

by the way how can i check for each table whats it "character-set"
set to?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

You can put :
set-variable=default-character-set=hebrew
in my.ini (which i think is in c:\windows) then restart mysql.
I'm not sure how (or even if) you can set a character set per table.
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

well i did it but no change i still see the default latin1?
Post Reply