Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL
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
Edited 11-Oct-12 7:18am
Maciej Los136.3K
v2
Comments
carlos.ma at 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
0 OriginalGriff 6,696
1 Sergey Alexandrovich Kryukov 6,675
2 CPallini 5,315
3 George Jonsson 3,584
4 Gihan Liyanage 2,650


Advertise | Privacy | Mobile
Web02 | 2.8.140921.1 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2014
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