Re: most popular places

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

 



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 pictures)
UNION
(select city_id from reports))
order by num





On Friday 25 February 2005 07:08 am, Merlin wrote:
> Hi there,
>
> 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  pictures  reports
> 3  4  3
> 2  9  8
> 9  8  8
>
> So the most used city_ids are
> 8
> 3
> 9
>
> To find this out would be a chelenging task, but to merge them with the
> city name is even more difficult
>
> I am working on this quite a while now and cant find a way. Maybe someone
> of you guys could give me a smart push.
>
> Thank you for any help,
>
> Merlin

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux