I have this old_table.
ID: First_name: Last_name: Age:
1 Christian Johnson 25
2 John Christiansen 21
3 <NULL> Peterson 23
and this new_table I just created, by this piece of code:
CREATE TABLE new_table (ID integer, name text, age text);
INSERT INTO new_table (ID, name, age) SELECT ID, First_name, age FROM old_table;
Which returned:
ID Name: Age:
1 Christian 25
2 John 21
3 <NULL> 23
But I would love my code to insert the lastname, if it encounters a NULL-value. So in pseudo-code;
(...) SELECT ID, First_name IF NULL last_name, age FROM old_table;
The IF NULL last_name doesn't work.