[thelist] RE: php array cleverness needed

rudy rudy937 at rogers.com
Wed Sep 3 06:26:21 CDT 2003


> It's always best to be clever in the query, if possible.  ;)

that's certainly the way i'd do it

however, the syntax Will gave won't work in mysql

try this

1. most commonly selected countries

    select country_name
      from country
     where country_count > 0
    order
        by country_count desc
    limit 5

just print that out

2. full country list array alphabetically

    select country_name
      from country
    order
        by country_name

just print that out


yes, you could make just one call to the database and then manipulate
results in your code in order to produce two separate lists, but hey, life's
too short to be coding things that the database can do nicely for you, and
the performance hit in this example of two calls to the database versus one
is going to be negligible


rudy



More information about the thelist mailing list