Link to home
Start Free TrialLog in
Avatar of morinia
moriniaFlag for United States of America

asked on

Select statement in SQL to create a new table

I would like to create a new table D  from all elements in table A, all elements in Table B but only two elements from Table C.  The two elements are Element_A and Element_B.
Can someone tell me the most efficient way to code this statement.
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

INTO will create a new table from the results of a query:

SELECT <columns>
INTO NewTableName
FROM <tables>
WHERE <criteria>

Your question does not really provide enough information to go much beyond that.
Avatar of morinia

ASKER

matthespatrick


The statement I have below is creating  table ER_Members_Cases.  The way it is coded now I am getting all of the columns from both Case_Members and ER_Case.  I was wondering if there was a way other than listing all of the columns to get all of the columns from one table using the * and only two columns from the other table.  FYI  this is a PROC statment in SAS using  PROC SQL

Create Table ER_Members_Cases as
      Select * From Case_Members m, ER_Case e
      where m.membno = e.membno;
Quit;
ASKER CERTIFIED SOLUTION
Avatar of ambidextrous
ambidextrous

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial