472,143 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,143 software developers and data experts.

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 1215
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
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.