Jump to content

Problem with what should be a simple query


mrherman

Recommended Posts

Hi --

 

This query seems to be problematic because the UPDATE is not being performed.  Could you please take a gander and let me know what is the problem?

 

BTW, the table "teamy" does contain 630 records.  Thanks in advance!

 

$sql = "SELECT COUNT( * ) AS records FROM teamy" ;
$result = mysql_query( $sql ) ;
if ( ! $result )
{ die ( __line__ . "_teamy_" . mysql_error() ) ; }

$a_count = mysql_fetch_assoc($result);
if ( $a_count['records'] = 0 )
{
   echo "No records found in teamy." ;
}
else
{ 
   /*** Update r_rost_rma ***/
   $sql = "UPDATE r_rost_rma 
             JOIN teamy
               ON r_rost_rma.student_id = teamy.student_id
              SET r_rost_rma.teachername = teamy.team
            WHERE RTRIM( UPPER( r_rost_rma.localcourse ) ) = 'HOMEROOM'" ;

   $result = mysql_query ( $sql ) ;
   if ( ! $result )
   { die ( __line__ . "_update_r_rost_rma_" . mysql_error() ) ; }
}

I truly do not understand any of your script (that's not your fault though - I'm not good in php) but one thing I notice is that in the $sql variable there are no ' 's.

$sql = "UPDATE r_rost_rma 
             JOIN teamy
               ON r_rost_rma.student_id = 'teamy.student_id'
              SET r_rost_rma.teachername = 'teamy.team'
            WHERE RTRIM( UPPER( r_rost_rma.localcourse ) ) = 'HOMEROOM'" ;

 

I do not know if this helps, only thing I know is after a '=' in a mysql statement I put ' 's around it.

Does the following query return any records:

SELECT * FROM r_rost_rma 
             JOIN teamy
               ON r_rost_rma.student_id = teamy.student_id
              SET r_rost_rma.teachername = teamy.team
            WHERE RTRIM( UPPER( r_rost_rma.localcourse ) ) = 'HOMEROOM'

Hi, samshel --

 

Thanks for your reply.  In continuing to play with this "problem," I have realized my error...As the script moves on, I had a little piece of code in there that actually deleted certain parts of the table, which made it APPEAR that the UPDATE was not working, when actually it was working.  Several hours!

 

Sound of windshield washers: dumb-guy! dumb-guy! dumb-guy!

 

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.