sql - Reference field in MySQL SET Query -


so have table looks likes this

+----+----------------------+--------------------------+----------+----------+ | id | fullname             | email                    | username | password | +----+----------------------+--------------------------+----------+----------+ |  1 | john doe             | johndoe@example.com      | johndoe  | password | |  2 | jane doe             | janedoe@example.com      | janedoe  | password |  +----+----------------------+--------------------------+----------+----------+ 

what want change "password" "1". example, table after query:

+----+----------------------+--------------------------+----------+----------+ | id | fullname             | email                    | username | password | +----+----------------------+--------------------------+----------+----------+ |  1 | john doe             | johndoe@example.com      | johndoe  | johndoe1 | |  2 | jane doe             | janedoe@example.com      | janedoe  | janedoe1 |  +----+----------------------+--------------------------+----------+----------+ 

i tried doing update table set password=username+"1" id=1; didn't work. no surprise there.

how this?

use concat

update table set password=concat(username,'1') ; 

demo


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -