Click here to Skip to main content
11,415,809 members (83,565 online)
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 6:53am
Edited 11-Oct-12 8:18am
Maciej Los178.1K
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 Sergey Alexandrovich Kryukov 9,270
1 OriginalGriff 7,512
2 Maciej Los 3,710
3 Abhinav S 3,325
4 Peter Leow 3,084


Advertise | Privacy | Mobile
Web03 | 2.8.150427.4 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2015
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