3

What query would insert the selected columns, for a desired value, from a table into another table?

Before Query

table1=>Colums(A,B,C)
  row1(a,b,1)
  row2(c,d,0)
  row3(e,f,1)

table2=>Columns(id,A,B)

After Query

table1 is unchanged.

table2(id,A,B)
  row1(id,a,b)
  row2(id,e,f)

I need to insert in table2 all the rows from table1 where 'C=1', C may equal 1 in multiple records.

Kevin
  • 2,234
  • 2
  • 21
  • 26
Maxim Alexandru
  • 79
  • 1
  • 4
  • 9

2 Answers2

11
INSERT INTO TABLE2(A,B,C)
SELECT A,B,C
FROM TABLE1
WHERE C = 1
T McKeown
  • 12,971
  • 1
  • 25
  • 32
0

you can also select all the columns into a table without creating it first:

SELECT *
INTO TABLE2
FROM TABLE1
WHERE C=1
rbedger
  • 1,177
  • 9
  • 20