[PHP] Re: ORDER BY from 2 tables

2002-07-29 Thread Paul Dionne

I am not sure what exactly you mean.  If you are talking about a regular 
query then:
SELECT tblTable1.hits, tblTable2.hits FROM tblTable1, tblTable2 ORDER BY 
tblTable1.hits;

If you are talking about combining the two tables so that all your 'hits' 
are in one column then there are a few ways to skin that cute little 
kitten (in order of difficulty):
1) Check to see if your databae supports UNION clauses. 
2) If not, make a table with the data from the first table then append the 
data from the second table.  Then query for your combined results and 
delete the table from the database.  You may run into problems if more than 
one person tries to do this at a time, so be careful.
3) Or. create an array using data from the first set then loop through the 
second set adding the data from the second set.  Then sort.

Good luck and keep us posted.

Paul


Georgie Casey wrote:

> i assume this is a simple question...
> 
> how can I SELECT * FROM 2 different tables in the same query, ORDER BYing
> the 'hits' column, which both tables have.
> 
> eg, 2 tables i have are similiar and i want to merge them and then select
> everything ordering by hits


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




[PHP] Re: ORDER BY from 2 tables

2002-07-29 Thread Philip Hallstrom

See if your database supports the UNION clause...

On Mon, 29 Jul 2002, Georgie Casey wrote:

> i assume this is a simple question...
>
> how can I SELECT * FROM 2 different tables in the same query, ORDER BYing
> the 'hits' column, which both tables have.
>
> eg, 2 tables i have are similiar and i want to merge them and then select
> everything ordering by hits
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


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