c# - Re-factor simple SQL statement with WHERE clause -


i feel there must more efficient way this. want allow caller either pull books, or books not hidden (see below)

if isnull(@showhiddenbooks, 0) = 1     begin         select             (long list of fields)                     mytable                     myfield = @somefield     end else     begin         select             (long list of fields)                     mytable                     myfield = @somefield ,             ishidden = 0         end 

any thoughts?

thanks!

select * mytable myfield = @somefield , (ishidden = 0 or @showhiddenbooks = 1) 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -