From: David Bruha Date: March 20 1999 2:35pm Subject: Isn't there any other way ? List-Archive: http://lists.mysql.com/mysql/685 Message-Id: <36F3B23C.31361E64@senior.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 8bit Hi, I've sent this question already once but nobody has answered. I'm very newbie to mysql and uncertain about some features and would really appreciate your help. I'm working on a www project and am using mysql only to retrieve stored data. Now I have encountered problem where I have to create a temporary table to be able to retrieve data in needed way. I have created following script in PHP3 to create output of products and accesories. Output is formated to the table where columns are accessories and rows are products. I print a bullet into those cells where the accessories belong to respective products. This script is included into respective pages and those pages provide variables $nazev[] & $nazev_link[]. My problem is that I have to create a temporary table. This script is included into cca 50 pages and I don't know how large amount of disk space I will have to my disposal. In Oracle one can use nested selects for this kind of problem but in mysql this feature is not available. Isn't there some other way how to access this problem? My script looks like: 0) { // Creating tmp table for selected accessories $table=mysql_db_query("wap", "create table temp (obj_c int(11), nazev varchar(60))"); // Insert dara into tmp table for ($i=0; $i<$rows; $i++) { $tmp_obj_c=mysql_result($res, $i, "doplnky.obj_c"); $tmp_nazev=mysql_result($res, $i, "doplnky.nazev"); mysql_db_query("wap", "insert into temp values ('$tmp_obj_c', '$tmp_nazev')"); } // Print Table of accessories echo("
| "); // Print table titles and run respective queries for ($i=0; $i < $pocet; $i++) { // titles of columns echo (" | Doplnky $nazev[$i] | "); // query for respective column (product) $sloupce[]=mysql_db_query("wap", "select id_doplnku, nazev from temp left join typy_doplnky on obj_c=id_doplnku and id_typu='$obj_c_vyrobku[$i]'"); } echo ("
| "); $pole=mysql_result($sloupce[0], $i, "nazev"); echo("$pole"); for ($j=0; $j<$pocet; $j++) { echo (" | ");
$pole=mysql_result($sloupce[$j], $i, "id_doplnku");
if ( $pole > 0 )
{
echo(" ");
}
else
{
echo(" ");
}
}
}
// Remove tmp table
mysql_db_query("wap", "drop table temp");
echo(" |