I have several thousands of the records and in a few hundred lines columns that are empty, I would like to save these rows in another table
i have this table :
id | name | lati | longi
1 | name1 | 47.482539 | 6.778554
2 | name2 | (empty) | (empty)
3 | name3 | 50.075055 | 1.97328
4 | name4 | 46.333055 | 7.99571
5 | name5 | (empty) | (empty)
I would like in new table to have this
id | name | lati | longi
1 | name2 | (empty) | (empty)
1 | name5 | (empty) | (empty)
what sql command can allow me to do this
thank you
CodePudding user response:
Almost all Rdms support CREATE TABLE SELECT
so you can make a query like this
CREATE TABLE table_new AS
SELECT id , name , lati, longi
FROM Table_olD WHERE lati IS NULL ANd longi IS NULL
SQL Server uses SELECT INTO table_name
see How to create a table from select query result in SQL Server 2008
The following
MySQL uses CREATE tABLe As SELECT
MySQL Create Table as SELECT
Oracle also usese CREATE TABLE AS SELCT
How to create table from SELECT statement in oracle 11g
Postgres uses also CREATE TABLe AS SELECT
Postgres - CREATE TABLE FROM SELECT
sqlite also follows the schema CREATE TABLe AS SELRCT
Copy table structure to new table in sqlite3