1

I have two tables

create table p ( x number, y number, z number ); create table q ( a number, b number, c number, d varchar2(20) ); 

I have inserted

insert into p values('1','2','3'); 

now i need to insert into q selecting values from p with last field getting name like Table _name in table q

values such that table q contains

a b c d 1 2 3 table_name 

plz help as soon as possible

1
  • You say that q contains "a b c d 1 2 3 table_name", but you mention only 4 fields in q. I don't understand that. Also, is "table_name" retrieved from somewhere or is it "hard-coded"? Commented Aug 14, 2009 at 10:17

2 Answers 2

2

INSERT INTO q(a, b, c, d) SELECT x, y, z, 'table_name' FROM p

Sign up to request clarification or add additional context in comments.

Comments

0
CREATE TABLE TestTable (FirstName VARCHAR(100), LastName VARCHAR(100)) INSERT INTO TestTable (FirstName, LastName) SELECT FirstName, LastName FROM Person.Contact WHERE EmailPromotion = 2 SELECT FirstName, LastName FROM TestTable DROP TABLE TestTable 

http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/

Comments