Re: [PHP-DB] most popular places

2005-03-15 Thread Kevin
Micah Stevens [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] With mysql 4.1 you could union and then subSelect maybe? I'm not super-familiar with sub selects, so this code won't likely run.. There is a unwritten rule that states: If your db needs the use of unions the db is set up

Re: [PHP-DB] most popular places

2005-02-25 Thread Joseph Crawford
the only way i can think of off the top of my head would not be intense as you would have to do a foreach for each of the cities such as $qry = select * from table $total = mysql_num_rows( $qry ); foreach( $cities as $city ) { // do db query such as // $qry = mysql_query(SELECT id FROM table

RE: [PHP-DB] most popular places

2005-02-25 Thread Bastien Koert
Use a join to get the city name Use grouping to group the most common cities select a.*, b.* from table1 a inner join table2 b on a.id = b.id [where clause] group by a.id Would need a little more data about the structure of the tables to give a more complete answer bastien From: Merlin [EMAIL

Re: [PHP-DB] most popular places

2005-02-25 Thread Martin Norland
Merlin wrote: I am trying to do a tricky task with PHP and MySQl 4.0.x There are 3 content tables where each of them contains a city_id and there is a 4th table which holds the city_id and the acording city_name Now I would like to find out the most used city names. For example: members

Re: [PHP-DB] most popular places

2005-02-25 Thread Micah Stevens
With mysql 4.1 you could union and then subSelect maybe? I'm not super-familiar with sub selects, so this code won't likely run.. But then, you're runn 4.0x so it won't run anyway. :) select city_id, count(city_id) as num from ((select city_id from members) UNION (select city_id from