Forums
This topic is locked
how to check if part is in a subquery
Posted 30 Jul 2010 00:11:55
1
has voted
30 Jul 2010 00:11:55 zachary anthony posted:
If X is a subquery of components that need to be sent out for platting and @ITEM is a component and @ADJUSTMENT is a varriable I need to write something that does the following:IF @ITEM IS IN X
SET @ADJUSTMENT = 7
ELSE
SET @ADJUSTMENT = 0
Help would be greately appreciated!
If you need to know, the subquery X returns nothing more or less than a list of items.
Replies
Replied 05 Aug 2010 10:36:24
05 Aug 2010 10:36:24 Patrick Woldberg replied:
I'm not sure what you exactly want to retrieve, so here are some examples which I hope will help you.
couldn't you just do a select in the if statement like:
or if you need to use a subquery to check if the item is for example in a specific category which is in a other table:
couldn't you just do a select in the if statement like:
IF EXISTS(SELECT NULL FROM Table WHERE Item = @ITEM)
or if you need to use a subquery to check if the item is for example in a specific category which is in a other table:
SELECT NULL FROM Items WHERE Item = @ITEM AND ItemId IN (SELECT ItemId FROM ItemCategories WHERE Cat = @CAT)