x

sql command

Table:product

 product_id   parent_id
 966          0   

If the table value like this

insert row and value into Table:custom

more ▼

asked Aug 08, 2012 at 03:37 AM in Default

avatar image

Yan0609
0 1 1 2

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

Seems like you need something like the following

 INSERT custom (COL1NAME, COL2NAME....OTHER COLUMNS)
 SELECT product_id, parent_id... OR ANY COLUMNNAMES
 FROM product
 WHERE product_id = 966 AND parent_id = 0
more ▼

answered Aug 08, 2012 at 05:32 AM

avatar image

Usman Butt
13.9k 6 13 21

If I don,t kNow which project id I just want to insert. The Id which is parent id =0

Aug 08, 2012 at 06:12 AM Yan0609

@Yan0609 Can you please give some test data and desired output to sort this out? But if I understand you correctly, you mean you just need to insert those rows where parentid = 0, then change the WHERE clause from

WHERE product_id = 966 AND parent_id = 0

to

WHERE parent_id = 0

Aug 08, 2012 at 06:33 AM Usman Butt
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x1069
x138

asked: Aug 08, 2012 at 03:37 AM

Seen: 519 times

Last Updated: Aug 08, 2012 at 07:21 AM

Copyright 2016 Redgate Software. Privacy Policy