Reputation: 11
my column value is
firstname
===============
mufi**alam
lam**slam
zia**busa
i want to oreder by after star in value. how we can usewhich query of mySql
Upvotes: 1
Views: 488
Reputation: 76
Try this
SELECT first_name FROM persons ORDER BY SUBSTRING_INDEX(first_name, '*', -1) [desc,asc];
here desc means descending order, asc means ascending order.
Upvotes: 0
Reputation: 8179
Try this query
SELECT firstname FROM persons
ORDER BY SUBSTRING_INDEX(firstname, '*', -1);
Output
| FIRSTNAME |
--------------
| mufi**alam |
| zia**busa |
| lam**slam |
Upvotes: 0
Reputation: 37243
try this
SELECT SUBSTRING_INDEX(firstname, '*', -1) AS foo FROM Table1
order by foo;
or this demo if you want show the firstname column
or this without foo column , just order by after *.
SELECT firstname FROM Table1
order by SUBSTRING_INDEX(firstname, '*', -1);
Upvotes: 1