Nike
Nike

Reputation: 101

insert 2 column primary key

I want to insert 2 column primary key ( X and Y) in table A. X is inserted from table B and Y inserted from a fixed value..

INSERT INTO A
  (X,Y) 
SELECT W 
  FROM table B, '1'

Upvotes: 1

Views: 178

Answers (1)

OMG Ponies
OMG Ponies

Reputation: 332701

You were close:

INSERT INTO A
  (X,Y) 
SELECT W, '1'
  FROM table B

Define the static value -- in this example, the text "1" -- as a column in the SELECT clause.

Only one FROM clause per SELECT clause. Additional SELECTs need to be within brackets/parenthesis...

Upvotes: 5

Related Questions