Re: Where to learn about these topics

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris Lott wrote:
Right-- but my question isn't about the query, but about the results.
Again, look at my result set:

+---------+----------+----------+-----------+-------+
| first   | last     | relation | city      | state |
+---------+----------+----------+-----------+-------+
| Chris   | Beks     | business | Fairbanks | AK    |
| Robert  | Hannon   | friend   | Fairbanks | AK    |
| Cindy   | Lott     | family   | Fresno    | CA    |
| Derryl  | Hartz    | business | Seattle   | WA    |
| Kirsten | O'Malley | friend   | Seattle   | WA    |
+---------+----------+----------+-----------+-------+

I want an output routine that does this:

CITY
  person
  person

CITY
  person

CITY person

There has to be a more elegant way than making a new query for each
city-- which is what the query I mentioned above fixes... but is the
kind of code I have put, with its ugly indexes and counters really the
best way? This is another area where books always stop at the simplest
cases...

Look at the MySQL documentation for 'DISTINCT' and 'GROUP BY'

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
john@xxxxxxxxxxxx

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux