0

I'm trying to store the concatenation of current date, and time from another table, based on a comparison of a column in that table, I've tried this code, but it gives me mysql syntax error.What is wrong?

My Code:

UPDATE daily_table
SET
task_datetime =  CASE
    when master_table.check_day = 'Today' then concat(curdate(),'   ',master_table.task_time)          
 when master_table.check_day = 'Tomorrow' then concat(   date_add(curdate(),interval 1 day) ,' ', master_table.task_time)
 CASE END

I'm using mysql and phpmyadmin.

user1930115
  • 995
  • 2
  • 11
  • 19

1 Answers1

0

You should JOIN master_table and daily_table.

This should help for you: How can I do an UPDATE statement with JOIN in SQL?

Should be something like this:

UPDATE daily_table dt
INNER JOIN master_table mt ON
    mt.col = dt.col
SET dt.taskdate = 
CASE
    WHEN mt.check_day = 'Today' THEN CONCAT(CURDATE(),'   ',mt.task_time)          
    WHEN mt.check_day = 'Tomorrow' THEN CONCAT(   DATE_ADD(CURDATE(),INTERVAL 1 DAY) ,' ', mt.task_time)
END
Community
  • 1
  • 1