Sql query for updating database if value is not null?

Without knowing your database it’s tough to be specific. In SQL Server the syntax would be something like … UPDATE MyTable SET Field1 = IsNull(@Field1, Field1), Field2 = IsNull(@Field2, Field2), Field3 = IsNull(@Field3, Field3) WHERE <your criteria here> EDIT Since you specified SQLLite …replace my IsNull function with COALESCE() or alternately look at the IfNull … Read more

MySQL ON UPDATE CURRENT_TIMESTAMP not updating

Have you tried to use null for that field when updating? You could also try setting default value to CURRENT_TIMESTAMP, rather than 0000-00-00 00:00:00. Nevertheless, whenever I want to have creation and update time I always use the following: … CREATED timestamp NOT NULL default ‘0000-00-00 00:00:00’, UPDATED timestamp NOT NULL default now() on update … Read more