var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Conditional logic?
I am attempting to add some conditional logic to a query. The basic premise is as follows (this query snippet does work!) -
I now want to go one step further by adding a SELECT statement that will ultimately determine how the @choice variable is set.
DECLARE @choice int
SET @choice = 0
IF @choice = 1
For example if a product code exists in the appropriate database table I want to set @choice to 1, otherwise set it to 0.
If anybody can suggest how I can go about this it will be greatly appreciated.
IF EXISTS (SELECT * FROM products WHERE product_code = '937')
SET @choice = 1;
SET @choice = 0;
David, you can also try something like this:
Hope this helps.
declare @choice int;
set @choice = coalesce((select 1 from products where product_code = 123), 0);
Thanks all for the wonderful suggestions.