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

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -