Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

SQL
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
Updated 11-Oct-12 7:18am
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.

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

SQL
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:
SQL
INSERT INTO product1 (pname, qty, pdesc, img1, img2)
SELECT pname, qty, pdesc, NULL AS img1, NULL AS img2
FROM product
 
Share this answer
 
v2
The query looks correct - check the types of the columns.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900