469,913 Members | 1,969 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,913 developers. It's quick & easy.

I am a newbie to mysql.plz help!.How to order the records in a table such that.......

28
How to order the records in a table such that the elements in a field strating with a particular alphabet apper first.

ie.,the elements in the field names are as follows:

amar
Bob
joy
mana
sana
xena

I want it as: If 'm' is my input then 'mana' must apper first but all the records must also appear.

something like this:
mana
sana
xena
amar
Bob
joy.

Hoping that anyone of you will help me>>>>>>>..

Thanks i advance.
-ram
Dec 15 '06 #1
1 1172
ronverdonk
4,258 Expert 4TB
Use a UNION to append the rows >= criteria with the rows < criteria, as follows:
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM table 
  2.       WHERE SUBSTR(name,1,1) >= 'M' 
  3.       UNION 
  4.       SELECT * FROM table 
  5.       WHERE SUBSTR(name,1,1) < 'M';
  6.  
Ronald :cool:
Dec 18 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Annie Xie | last post: by
reply views Thread by Yun Guan | last post: by
8 posts views Thread by wizardry | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.