sql server - Two sql if statements -
i want run through 2 if
statements in sql. if's 2 different conditions, example:
if (@user == 'bob') begin select * table id = 1 end if (@animal == 'cat') begin select * table id = 50 end
what want rows 1 if first condition correct or 1 , 50 if both conditions met. fails @ second if
statement, there keyword need add?
i recommend single statement:
select * table (@user = 'bob' , id = 1) or (@animal= 'cat' , id = 50)
Comments
Post a Comment