I am trying to construct INSERT sentences from a query like below:
INSERT INTO MyTable (Field1, Field2) VALUES (value1,value2);
So I do:
SELECT CONCAT('INSERT INTO MyTable (Field1, Field2) VALUES (', value1, ',', value2, ');')
FROM OneTable
The problem I have is that sometimes, value1 may be NULL so in the result I need to obtain things like:
INSERT INTO MyTable (Field1, Field2) VALUES (NULL,5);
how can I do this?