i have table like this, How do i compare this simple value with IF
statement
i want to compare j_path column's value with j_foto's value based on their s_username, IF j_path's value and j_foto's value SAME, then the score column would be same, example in admin: is 8.
IF j_path's value and j_foto's value NOT THE SAME, then the score column would be j_foto. sorry for my beginner, appreciate your help. thanks
To be honest, your rules reduce to just using the value in j_foto
:
update t
set score = j_foto;
Conditional logic is not needed for what you describe.
You may have the situation where j_foto
is NULL
and in that case you might want j_path
(although this situation is not mentioned in the question nor suggested by the data). In that case, use coalesce()
:
update t
set score = coalesce(j_foto, j_path);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.