Full Text sort order question

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Full Text sort order question

Post by AGISB »

I am using following full text serach

Code: Select all

SELECT GID, Descript FROM Ingrediences WHERE MATCH(Descript) AGAINST ('Apple')
The list contains all kinds of Apple entries that I like to be sorted by string length.

Apple as shortest should be on top followed by e.g. "Apple, fresh" and "Apple, fresh tinned"

Can that be done by the query or do I have to resort in php?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Probably

Code: Select all

... ORDER BY LENGTH(Descript)
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

It really sucks to own multiple 1000 page MySQL Books that never mention LENGHT

Thanks
Post Reply