开发者

idea to write procedure? [closed]

开发者 https://www.devze.com 2023-01-10 23:43 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

i pass parameter as productid, i check in productrelated table whether this product related product are there or not if it is no开发者_StackOverflow社区t there i want to check sample productid in departmentreplated table if it is not there i find the department of the productid and find the that productid related department product..

Plz help me how to write the store procedure.... which logic i want to use....

help me writing procedure.... reply as soon as ... thanks...


I guess you really want an answer on this and tried your best to formulate the question.

The way you describe it you need to do that with a SELECT statement that does a LEFT JOIN. I cannot help you with the store procedure on SQL-SERVER but I guess you can figure out the rest once you have the SELECT.

SELECT ISNULL(p.someValue, d.someValue)
FROM DepartmentRelatedTable d
LEFT JOIN ProductRelatedTable p on (d.ProductId = p.ProductId)
WHERE d.ProductId = <some id here>

You maybe need to do a FULL JOIN instead of a LEFT JOIN because. I could not fully understand the data model you are using.

0

精彩评论

暂无评论...
验证码 换一张
取 消