Reputation:
I need one help.I need to fetch value according to the one certain order using PHP and Mysql.I am explaining my table below.
db_subcategory:
id cat_id name order
1 10 happy hour 1
2 10 wine 3
3 10 water 2
4 11 pizza 1
5 10 beer 2
Here i need query
in Mysql to fetch all name whose cat_id=10
according to the order.It should come as per order1,2,3...
if for order value 2
there are two set of name,in this case the name will come alphabetically.Please help me.
Upvotes: 0
Views: 37
Reputation: 4236
SELECT name
FROM db_subcategory
WHERE cat_id = 10
ORDER BY `order`, name
EDIT: It might also needed to add backticks for order because it is a keyword.
Demo.
Upvotes: 1
Reputation: 6065
Order by
with two columns will do.
select * from db_subcategory where cat_id = 10 order by order, name
Upvotes: 0