Click here to Skip to main content
13,139,132 members (80,332 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
1... product (pname, pdesc, qty)
2... product1(pname, img1, img2, pdesc, qty)
actually there are two more (img1, img2) columns added as required, so new table created product

have tried this out

insert into product1 (pname, qty, pdesc)
select pname, qty, pdesc from product


maybe it contains errorful code, (little lack of knowledge in sql)

so just do me a favor, and rewrite it again... please
Posted 11-Oct-12 5:53am
Updated 11-Oct-12 7:18am
Maciej Los255.6K
v2
Comments
carlos.ma 11-Oct-12 12:30pm
   
Hi, I have tested your query and it's running ok, so I think that the problem may be the type of data that you are using for the columns or if the second table (product1) doesn't allow null values for the rest of the fields that are not being inserted. It could help if you specify the type of error you are getting from SQL.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

If img1 and img2 are required fields, add anything to these fields.

INSERT INTO product1 (pname, qty, pdesc, img1, img2)
SELECT pname, qty, pdesc, 0 AS img1, 0 AS img2
FROM product


If nullable values are accepted, try this query:
INSERT INTO product1 (pname, qty, pdesc, img1, img2)
SELECT pname, qty, pdesc, NULL AS img1, NULL AS img2
FROM product
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

The query looks correct - check the types of the columns.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.170915.1 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100