x
login about faq Site discussion (meta-askssc)

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 '12 at 03:37 AM in Default

Yan0609 gravatar image

Yan0609
0 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 '12 at 05:32 AM

Usman Butt gravatar image

Usman Butt
13.8k 6 8 14

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

Aug 08 '12 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 '12 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



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x914
x91

asked: Aug 08 '12 at 03:37 AM

Seen: 224 times

Last Updated: Aug 08 '12 at 07:21 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.