Page 1 of 1

A problem with a temp table

Posted: Mon Mar 17, 2003 10:00 am
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.

Posted: Mon Mar 17, 2003 10:17 am
by McGruff
Use mysql_affected_rows() for an INSERT.