Search
 
SCRIPT & CODE EXAMPLE
 

SQL

SQL Avoid Duplicates in INSERT INTO SELECT

INSERT INTO OldCustomers(customer_id, age)
SELECT customer_id, age
FROM Customers
WHERE NOT EXISTS(
  SELECT customer_id
  FROM OldCustomers
  WHERE OldCustomers.customer_id = Customers.customer_id
);
Comment

PREVIOUS NEXT
Code Example
Sql :: oracle previous year 
Sql :: query to find second highest salary 
Sql :: Using GROUP BY in MySQL Join Table 
Sql :: postgresql function round 
Sql :: delete from IN subquery 
Sql :: mysql with 
Sql :: format the money fied with comma in international system using sql 
Sql :: delete from inner join sql 
Sql :: Write an SQL query to print details of the Workers whose SALARY lies between 100000 and 500000. 
Sql :: sql last time database was accessed 
Sql :: oracle group 
Sql :: distinct in sql server 
Sql :: mysql run script 
Sql :: sql select all records from all tables where not empty 
Sql :: between vs in sql 
Sql :: how to define a save method in ruby for sqlite3 databases 
Sql :: oracle error compilation line 
Sql :: python sqlite3 search 
Sql :: how to insert a uniqueidentifier in sql 
Sql :: change from not null postgresql 
Sql :: sql primary key constraint 
Sql :: how to find 2nd highest salary in a table 
Sql :: sql remove duplicate 
Sql :: Create the connection pool mysql2 
Sql :: soql update query 
Sql :: download sql server 2014 
Sql :: declare date variable sql 
Sql :: sql exemplos 
Sql :: sql where is not number 
Sql :: insert multiple rows from another table sql 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =