Jump to content

[SOLVED] Update Column only in an sql statement


johntp

Recommended Posts

Hey guys,

 

I'm not sure how to set this up. I want to update only one column in a row in php.

 

when i try

 

<? $query  = "REPLACE INTO visitors (TimeOut) VALUES ( '$TimeOut') WHERE EmployeeID = '$Employee'; ?>

 

but it needs a value for all of my columns in that row to update.

REPLACE INTO works well, but you have to read the syntax. There shouldn't be a WHERE clause - it takes a primary or unique column and if a duplicate exists, it updates rather than inserts.

 

<? $query  = "REPLACE INTO visitors (EmployeeID, TimeOut) VALUES ('$Employee', '$TimeOut')"; ?>

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.