RE: [PHP] getting rows from separate tables stacked in a single a rray ? (newbie, mysql)

From: Date: Wed, 25 Apr 2001 07:46:07 +0000
Subject: RE: [PHP] getting rows from separate tables stacked in a single a rray ? (newbie, mysql)
Groups: php.general 
Request: Send a blank email to php-general+get-50248@lists.php.net to get a copy of this message
hey, why not to have one single query? or.. INSERT INTO tmp_table SELECT * FROM first_table; INSERT INTO tmp_table SELECT * FROM second_table; ... do a query on tmp_table, DELETE FROM tmp_table; but, isn't it better to have one table only? - you'll skipp three steps. Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) maxim@phpbeginner.com www.phpbeginner.com -----Original Message----- From: himself@nicolas-mermet.com [mailto:himself@nicolas-mermet.com] Sent: Wednesday, April 25, 2001 5:42 AM To: php-general@lists.php.net Subject: [PHP] getting rows from separate tables stacked in a single array ? (newbie, mysql) Hi. This will probably sound simple to all of you but I am hitting my head on a brick wall so far :-). I need to generate a list (sorted by descending time) of different objects referenced in multiple tables. All those objects share a key related to a project. This works splendidly from a single table : $sql="select * from storyboards, where spot_id = \"$spot_id\" order by date_posted desc"; $result=MySQL_query($sql,$db); while($row=MySQL_fetch_array($result)) { $qt_title = $row["title"]; $qt_duration = $row["duration"]; $qt_date_posted = $row["date_posted"]; //(timestamp) $qt_description = $row["description"]; $qt_id = $row["quicktime_id"]; } Is there a mysql query that would allow me to stack complete rows in multiple tables at once (It seems more elegant because I can sort them while extracting them) or is there a way in PHP to concatenate results in a single array and then sort them by time... ? I tried to use a join query, wich produced an invalid query error. (I think it tries to produce a table with merged data, not just a stack of rows). $sql4="select * from quicktimes, other_images, storyboards, where quicktimes.spot_id, other_images.spot_id, storyboards.spot_id = \"$spot_id\" order by date_posted desc"; thank you for your help ! nicolas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#50248) next »