Jump to content

practicing with temp tables - is this written right?


turpentyne

Recommended Posts

I'm trying to figure out how to create a temporary table of a query join, so I can paginate the results. I kind of made half of this up as i was going along - which is dangerous for a beginner like me.

I'm getting this error, and no results on the page:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource on line 179

 

also, is there a way to combine the two queries (create temp and insert from/into)

 

 

$sql2 = "CREATE TEMPORARY TABLE temp_search 
    (plant_id INT PRIMARY KEY AUTO_INCREMENT, 
     scientific_name VARCHAR(75),
     common_name VARCHAR(75),
     leaf_shape VARCHAR(75))";

$sqlx = "SELECT
                        descriptors.leaf_shape
                        ,plantae.scientific_name, plantae.common_name
                    FROM
                        descriptors
                    INNER JOIN
                        plantae ON (descriptors.plant_id = plantae.plant_name)
                    WHERE
                        descriptors.leaf_shape LIKE 'auriculate'
                        AND descriptors.leaf_venation LIKE '%$select3%'
                        AND descriptors.leaf_margin LIKE '%$select4%'

                    INTO temp_search (leaf_shape, scientific_name, common_name)";

$sql = "SELECT * FROM temp_search ORDER BY scientific_name ASC LIMIT $start, $limit";

$result = mysql_query($sql);


	while($row = mysql_fetch_array($result))
	{
echo  $row['scientific_name'] . $row['common_name'] . $row['leaf_shape'] ;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.