Friday, May 21, 2010

Finally my Discrete Math class pay off

I am writing a long and complicated stored procedure. Basically it is like
"if A is true, then
  SELECT blabla FROM bla WHERE (B = true)
otherwise,
  SELECT blabla FROM bla WHERE (B = false)"

I don't want to write CASE WHEN; and I don't want to repeat the common SELECT stuff. So this is what I do:
"SELECT blabla FROM bla WHERE (A = false OR B = true)"
 This is because "if X then Y" is logically equivalent to "not X or Y"

1 comment: