Created
November 25, 2015 21:43
-
-
Save stevewithington/1a5aa87196e972769674 to your computer and use it in GitHub Desktop.
SQL: When you need a if / else / then in your WHERE clause, this might help ...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET @someVar = 'someValue'; | |
SELECT * | |
FROM t_sometable | |
WHERE CASE @someVar <> '' THEN someColumn = @someVar ELSE someColumn = '' END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment