see you have a table name employee like below
table name employee
id name grade
1 Mahesh A
2 Vikrant B
3 Vikas C
4 Pankaj D
if you want to fetch these record in a specific order like D, B, C, A
then, you have to use ORDER BY FIELD clause in mysql.
e.g.,
SELECT * FROM employee
ORDER BY FIELD(grade, 'D', 'B', 'C', 'A');
now the output of above query will be:
id name grade
4 Pankaj D2 Vikrant B
3 Vikas C
1 Mahesh A
Wonderful blog & good post.Its really helpful for me, awaiting for more new post. Keep Blogging!
ReplyDeleteHire PHP Developers in India