Thread: SQL sorting
View Single Post
Old 23-05-2007, 15:27   #1 (permalink)
gk
geek
 
gk's Avatar
 
Join Date: Oct 2006
Location: *.everywhere
Posts: 204
Send a message via ICQ to gk Send a message via AIM to gk Send a message via MSN to gk Send a message via Yahoo to gk
SQL sorting

I want to do a query on items but also have groups listed and sorted by name. My tables are:
Code:
groups --------- id name items --------- id name group_id
and I have an sql statement like:
Code:
SELECT `items`.`id`,`items`.`name` FROM `items` LEFT JOIN `groups` ON `items`.`group_id`=`groups`.`id` ORDER BY `name`LIMIT 10,10
but that doesn't work. what I need is to have groups.name and items.name combined and sorted alphabetically.

I can think of one way to do it (dumping the results to a temporary table then sort in another select) but am wondering which is the better or if there is a another way.
__________________
Quote:
"Why reinvent the wheel"? Simply because it's not round enough and I don't like the treads.
  Reply With Quote