I wish to write two nested queries of create and select statements. My motive is to create a new table which includes columns and entries from two other tables. I wrote a query but it is giving me an error.
create table table_3(select * from table_1,table_2)
For SQL Server you can use:
SELECT *
INTO table_3
FROM table_1, table_2
If you want to join the two tables based on some key then:
SELECT *
INTO table_3
FROM table_1 JOIN table_2 on table_1.ID = table_2.FKID
You may see: SQL SERVER – CTAS – Create Table As SELECT – What is CTAS?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With