User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 422,977 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,934 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 6172 | Replies: 2
Reply
Join Date: Jan 2006
Posts: 221
Reputation: katharnakh is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 20
katharnakh's Avatar
katharnakh katharnakh is offline Offline
Posting Whiz in Training

Help MySQL insert statement

  #1  
Jul 11th, 2006
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.
Last edited by katharnakh : Jul 11th, 2006 at 6:01 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2005
Location: Manchester, UK
Posts: 482
Reputation: pty is on a distinguished road 
Rep Power: 3
Solved Threads: 33
pty's Avatar
pty pty is offline Offline
Posting Pro in Training

Re: MySQL insert statement

  #2  
Jul 11th, 2006
Originally Posted by katharnakh
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
Reply With Quote  
Join Date: Jul 2006
Posts: 7
Reputation: Vote4WillFree is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Vote4WillFree Vote4WillFree is offline Offline
Newbie Poster

Re: MySQL insert statement

  #3  
Jul 12th, 2006
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.
Last edited by Vote4WillFree : Jul 12th, 2006 at 9:03 am.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MySQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

All times are GMT -4. The time now is 3:19 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC