Mysql update query with IF statement -
I'm learning to use mysql so I actually created a simple project manager program. I wanted to know if a user saw it in a project. So I want to update the user_seen_task registered by the user when a project asks the user, but obviously I just want to update this field if it is not already set.
This is what I have my views have already:
function SET user_seen_task = 1, user_seen_task_date = now () WHERE project_id = 14 and User = 4 and user_seen_job! Update = 1 Unfortunately this query updates user_seen_task_date every time it runs.
Any help is greatly appreciated.
update tasks set user_seen_task = 1, user_seen_task_date = case when user_seen_task_date is zero now ( ) And end user_seen_task_date where PROJECT_ID = 14 and user = 4 and user_seen_job! = 1 or if it does not need to update user_seen_task in this case, just enter your
in your and add user_seen_task_date work Stiu user_seen_task = 1 update, user_seen_task_date = NOW () WHERE project Ect_id = 14 and user = 4 and user_seen_job! = 1 and user_seen_task_date IS Null
Comments
Post a Comment