Search
 
SCRIPT & CODE EXAMPLE
 

SQL

insert a select statement into a table

--format
INSERT INTO Customers (CustomerName, City, Country)
SELECT SupplierName, City, Country FROM Suppliers;

--examples
INSERT INTO Customers (CustomerName, City, Country)
SELECT SupplierName, City, Country FROM Suppliers;
Comment

select insert with own query

INSERT INTO user_profile (
    name, 
    client_id, 
    email_id,
    mobile,
    create_date,
    last_modified
)
SELECT 
    name, 
    client_id, 
    email_id,
    mobile,
    now(),
    now()
FROM 
    user_profile
WHERE 
    id = 106
Comment

sql server insert into select

INSERT INTO sales.addresses (street, city, state, zip_code) 
SELECT
    street,
    city,
    state,
    zip_code
FROM
    sales.customers
ORDER BY
    first_name,
    last_name; 
Comment

insert into values select

INSERT INTO my_table SELECT * FROM source_table;
INSERT INTO my_table (a, b, c) SELECT a, b, c FROM source_table;
INSERT INTO my_table (a, b, c) SELECT a, b, c FROM source_table s
	WHERE s.my_col >= 10;
Comment

insert select

INSERT INTO table2
SELECT * FROM table1
WHERE condition;
Comment

SQL Server INSERT INTO SELECT

 INSERT INTO table1
 SELECT col1, col2 , col3 FROM table2
 WHERE your condition;
Comment

SQL Server INSERT INTO SELECT

 INSERT INTO salesTransaction_History
 SELECT * FROM salesTransaction
 WHERE item_Number='Salt-1';
Comment

SQL INSERT INTO SELECT Statement

INSERT INTO OldCustomers
SELECT *
FROM Customers;
Comment

select from table and insert into table in sql

INSERT INTO table_name(column_list)
SELECT 
   select_list 
FROM 
   another_table
WHERE
   condition;
Code language: SQL (Structured Query Language) (sql)
Comment

PREVIOUS NEXT
Code Example
Sql :: join vs inner join 
Sql :: sql union 
Sql :: microsoft sql server management studio uppercase shortcut 
Sql :: how to avoid duplicate records in sqlite 
Sql :: mysql delete duplicate rows except one 
Sql :: .env pgsql 
Sql :: keys in sql with example 
Sql :: psql store procedure-return multiple table values 
Sql :: sql merge statement 
Sql :: import sql file to mysql db using shell commands 
Sql :: order by in codeigniter query builder 
Sql :: find current server name for SSMS 
Sql :: into operator in sql 
Sql :: how to increase the width of the screen in oracle 
Sql :: select indexname psql 
Sql :: set value to null postgres 
Sql :: sql commands 
Sql :: alter table add multiple columns mysql 
Sql :: order by postgres 
Sql :: data types mysql vs postgresql 
Sql :: column must appear in the GROUP BY clause or be used in an aggregate function 
Sql :: drop constraint in ms sql 
Sql :: psql view databases 
Sql :: sql server port number 
Sql :: union sql 
Sql :: mysqldump 
Sql :: is not null sql 
Sql :: non relational database 
Sql :: sql online code 
Sql :: nosqlbooster query other collection 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =