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() ) ; }
}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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'

Link to comment
Share on other sites

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!

 

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.