0

Iam inserting multiple records from one table to another table like

INSERT INTO table3 ( iSysRecDeleted, iUserId ) SELECT table2.iDeleteId, (SELECT iUserIdOld FROM table1 WHERE table1.col1=table2.col2) FROM table2 

But it is giving me "Sub query returns more than 1 row".iUserIdOld had multiple entries with repetive in table1.Also I have to insert column3 from another table which will be not relevant to table1 and table2 so I don't have to use Join.Could anyone please tell me to do it in a right way. Thanks in advance.

1 Answer 1

1

Try this:

INSERT INTO table3 ( iSysRecDeleted, iUserId ) SELECT table2.iDeleteId, table1.iUserIdOld from table2 join table1 on table1.col1=table2.col2 
Sign up to request clarification or add additional context in comments.

3 Comments

@Gautam3164 That means? There is nothing in your question, that shows your new problem.
@Jens please see the edited question..Till I dont want to insert 3rd column from another table your query is working fine
@Gautam3164 Can you show some more deatils so that I can understand the problem? Where the third column comes from and how can you get a single reord from this.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.