I'm having problem in inserting into table. I'm inserting data from one table into another

insert into table1 select * from table2 where condition = expression

I have 962 records in table2 for specified condition, but only 105 rows are getting inserted.

Both tables are in same database.

What could be problem? Please help me to get out of this problem.

Recommended Answers

All 2 Replies

I'm having problem in inserting into table. I'm inserting data from one table into another

insert into table1 select * from table2 where condition = expression

I have 962 records in table2 for specified condition, but only 105 rows are getting inserted.

Both tables are in same database.

What could be problem? Please help me to get out of this problem.

your expression is probably wrong, however, it is difficult to diagnose unless you post it and some of your schema

The insertion sql statement should be something like:

INSERT INTO TABLE (column1, column2)
SELECT column1, column2 FROM TABLE2 WHERE column3 = 4

make sure that the number of columns are the same and in the same order

Hope it helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.