Welcome Guest, Not a member yet? Register   Sign In
how to create queries like this...
#11

[eluser]davidbehler[/eluser]
Sure, you can order by as many fields as you want.
What it does is this:
It orders the result alphabetically by the first field (in this case district_name). As there are multiple rows with the same district_name they can't be ordered properly and some default order would be in place for them (propably by primary key). Anyway, those with the same district_name will be ordered again, this time by city_name.

Take this example:
Code:
Un-ordered:
district_name | city_name
--------------------------
country 1 | test city
country 2 | other city
country 1 | more city
country 1 | city2000
country 2 | big_city
country 3 | small_city
country 2 | medium_city

order by district name asc, city_name asc:
district_name | city_name
--------------------------
country 1 | city2000
country 1 | more city
country 1 | test city
country 2 | big_city
country 2 | medium_city
country 2 | other city
country 3 | small_city


Messages In This Thread
how to create queries like this... - by El Forum - 07-29-2010, 02:53 AM
how to create queries like this... - by El Forum - 07-29-2010, 02:57 AM
how to create queries like this... - by El Forum - 07-29-2010, 03:01 AM
how to create queries like this... - by El Forum - 07-29-2010, 03:28 AM
how to create queries like this... - by El Forum - 07-29-2010, 03:29 AM
how to create queries like this... - by El Forum - 07-29-2010, 03:36 AM
how to create queries like this... - by El Forum - 07-29-2010, 03:44 AM
how to create queries like this... - by El Forum - 07-29-2010, 03:47 AM
how to create queries like this... - by El Forum - 07-29-2010, 03:53 AM
how to create queries like this... - by El Forum - 07-29-2010, 04:05 AM
how to create queries like this... - by El Forum - 07-29-2010, 04:08 AM
how to create queries like this... - by El Forum - 07-29-2010, 04:11 AM
how to create queries like this... - by El Forum - 07-29-2010, 04:22 AM
how to create queries like this... - by El Forum - 07-29-2010, 04:24 AM
how to create queries like this... - by El Forum - 07-29-2010, 04:26 AM
how to create queries like this... - by El Forum - 07-29-2010, 04:30 AM
how to create queries like this... - by El Forum - 07-29-2010, 04:33 AM
how to create queries like this... - by El Forum - 07-29-2010, 04:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB