A problem with a temp table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
smoky989
Forum Commoner
Posts: 41
Joined: Mon Sep 02, 2002 1:14 pm

A problem with a temp table

Post by smoky989 »

I have 3 fields from 3 tables I want to combine into a temp table. They are all named the same and they are all the same datatype. The syntax I got for the temp table came from what I read at mysql.com. I'm getting an error in the mysql_num_rows() function. Can anyone see a problem with my code.

їcode]db_connect(); //connects to DB

mysql_query("CREATE TEMPORARY TABLE temp_table (
`w_name` VARCHAR( 50 ) NOT NULL ,
`artist` VARCHAR( 100 ) NOT NULL ,
`song` VARCHAR( 100 ) NOT NULL)");

$result = mysql_query("INSERT INTO temp_table (w_name) SELECT roster.w_name FROM roster");

$num_results=mysql_num_rows($result);
ї/code]

I do not have mysql 4.0.xx running on my server so I can not use the UNION operator which would be a great solution right now. Any ideas? Thanks in advance.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Use mysql_affected_rows() for an INSERT.
Post Reply