tags:

views:

21

answers:

1

Hello,

I have two MySQL tables, one with categories and one with products. For the first one, I also have a column which describes the category order. What I want to do is get all the products and sort them by category (which needs to be sorted ascending according to the 'order' field) and by price (also ascending).

The tables are:

categories
-id, (int)
- name, (text)
- order (int) 

products
- id, (int)
- model, (text)
- price, (float)
- category_id (int)
+2  A: 
Select id, model, price
from products p , categories c
where c.id = p.category_Id
order by c.order, p.price
Michael Pakhantsov
Does it work for more than one category and more than one product in each category?
Psyche
@Psyche, it will sort recordset by category order, inside each category by price (from lowest to highest)
Michael Pakhantsov