Re: Problem with SQL query on several tables

From: Date: Tue, 27 Nov 2001 18:53:17 +0000
Subject: Re: Problem with SQL query on several tables
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-14616@lists.php.net to get a copy of this message
It sounds to me like what you're trying to do is APPEND data from three similarly structured tables into one entity ordered by a column common to all 3 tables called "datestamp". If I'm mistaken, then please ignore all of the following: Approach #1 (mysql) Create a temporary table with the columns you need to process, indexed by "datestamp", and append the data from the 3 tables-- then query the temp table. Approach #2 (php) Create an associative array (hash table) in php then append the data from the 3 tables, order as desired, and process. Which you choose would depend on which you find simpler-- the mysql approach would probably take a more time, but be easier to reuse on successive pages. ib Rosen wrote:
Thanks, but I want wo JOIN data from three tables and then to order all data by "datestamp". Can I Do It ? Thanks, Rosen Andrey Hristov wrote in message <071401c17759$f5873c80$0b01a8c0@ANDreY>...
Mysql says that in the join there are some columns with namer datestamp so
you have to choose by which you want to order.
Think about making LEFT JOIN. select * from f1 LEFT JOIN f2 ON f1.some_field=f2.some_field LEFT JOIN f3
ON f2.some_field=f3.some_field roder by f1.datestamp;
Regards, Andrey Hristov IcyGEN Corporation http://www.icygen.com BALANCED SOLUTIONS ----- Original Message ----- From: "Rosen" <rosen_dm@hotmail.com> To: <php-db@lists.php.net> Sent: Tuesday, November 27, 2001 5:34 PM Subject: [PHP-DB] Problem with SQL query on several tables
Hi, I'm trying to execute SQL query: "select * from f1,f2,f3 order by datestamp" MySQL returns me an error: "1052 - Column: 'datestamp' in order clause is ambigious" The tables f1,f2,f3 have some structure. The field "datestamp" is type datetime. Why I can't order query on 'datestamp' ? Thanks, Rosen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net


« previous php.db (#14616) next »