chris chris - 1 year ago 138
MySQL Question

CodeIgniter single update query to update one column with an existing columns data?

In my db I have a Last and a Current column for datetime. Just to keep an eye on when someone last used a valid login to the service I am building up.

What I want to know is, is it possible to update one column on a row with another column from that row, while updating the other column at the same time

Ie: Set the Last as the current Current, then set the Current with the date thats right now essentially?

Make any sense?

Answer Source

Try like this ..

$data=array('last_login'=>current_login,'current_login'=>date('Y-m-d H:i:s'));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download