Insert output of a query into a new table

baijuep
 
on Feb 26, 2013 08:47 AM
1916 Views

I have query and it works fine i want to insert the output of the query into a table named baiju. 

the query is as under

SELECT Employees.*
FROM Employees
WHERE (((Employees.Qualification)="LED" Or (Employees.Qualification)="MED") AND ((Employees.ID) In (SELECT ID FROM Employees WHERE Qualification = 'OY'))) OR (((Employees.Qualification)="OTY"));

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
Mustafa
 
on Feb 26, 2013 09:05 AM
INSERT INTO baiju 
(SELECT Employees.*
FROM Employees
WHERE (((Employees.Qualification)="LED"
OR (Employees.Qualification)="MED")
AND ((Employees.ID) IN (SELECT ID FROM Employees WHERE Qualification = 'OY')))
OR (((Employees.Qualification)="OTY")))

Note: This query will work only if you have all the columns same in both baiju and Employees Table

If you don't have same Columns in both the tables than you will have to specify the column Names like this

INSERT INTO baiju (COLUMN1, COLUMN2, COLUMN3)
(SELECT Employees.COLUMN1, Employees. COLUMN2, Employees.COLUMN3
FROM Employees
WHERE (((Employees.Qualification)="LED"
OR (Employees.Qualification)="MED")
AND ((Employees.ID) IN (SELECT ID FROM Employees WHERE Qualification = 'OY')))
OR (((Employees.Qualification)="OTY")))