Bunion Bunion - 3 months ago 8
MySQL Question

Insert INTO table where one table has a NOT NULL

I have two identical tables bar one column, (one live, one test)

The test table has an extra not null Column called "MatchOrderNo"

I'm trying to extract data from Live to test, how can i populate this not Null for all rows?

basically my current statement is

INSERT INTO test SELECT * FROM live;

Answer

You can use a Default value like:

INSERT INTO test SELECT live.col1, live.co2, '1' FROM live;