creating temp table from results of 2 static tables
Posted: Sun Feb 15, 2004 12:33 pm
hi, i need to create a temporary (mysql) table which contains results from 2 static tables. i use this code, where $_SESSION['query_one'] and $_SESSION['query_two'] contain select query strings for table1 and table2:
i always get "Query failed" when executing it, but when i run the $temp_table_query in PHPMyAdmin it works.
what is wrong? can i have 1 temp table containing 2 static tables at all?
if not why does it work in PHPMyAdmin?
i forgot to say that the two static tables have same structure and that i'm using mysql 3.23.47-nt, so i can't use UNION since it is available only in mysql 4 according to the manual.
thanx
Code: Select all
<?php
$joined_query = ($_SESSION['query_one'].";".$_SESSION['query_two']);
$temp_table_query = "CREATE TEMPORARY TABLE tmp $joined_query";
if (!mysql_query($temp_table_query, $connection)) { echo"<script>alert('Query failed')</script>"; }
?>what is wrong? can i have 1 temp table containing 2 static tables at all?
if not why does it work in PHPMyAdmin?
i forgot to say that the two static tables have same structure and that i'm using mysql 3.23.47-nt, so i can't use UNION since it is available only in mysql 4 according to the manual.
thanx