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'] ;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.