I have some values in a PHP script that I must insert in a MySQL table. Here is for example 3 dates d1, d2, and d3.
I have that default statement to insert the values into the database:
insert into mytable set a=1, b=2, d1='$val', d2='$val2', d3='$val3'
Is there a very simple way I can write the SQL statement to insert into d1, d2 and d3 NULL values instead of a date if one (or more) of $val1, $val2 and $val3 is nil ? Without having to deal with new PHP variables?
I found that way to be the simpliest way to do what I wanted to do: