Shane
Shane

Reputation: 753

move data from one column to another mysql

I am wanting to move data from one column to another in a MySQL table.

Here is my code:

   $sDate = date("d-m-Y H:i:s");

mysql_query( "   UPDATE users
SET 
  logintimelast = logintime 

AND 
  logintime = '$sDate'");

However this does not update either column?

Upvotes: 0

Views: 226

Answers (1)

Explosion Pills
Explosion Pills

Reputation: 191819

Because your syntax is wrong. lotintime AND logintime = '$sDate' is a boolean expression.

SET
    logintimelast = logintime,
    logintime = '$sDate'

Your query is vulnerable to injection. You should stop using ext/mysql and use properly parameterized queries with PDO or mysqli

Upvotes: 4

Related Questions