Created
August 12, 2012 18:35
-
-
Save hunterloftis/3333630 to your computer and use it in GitHub Desktop.
Attempted CASE query
This file contains hidden or 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
-- Doesn't work (returns affiliation = null): | |
SELECT dating.*, | |
CASE WHEN dating.traditional = choices.id AND choices.cat = 'trad' THEN choices.choice END as affiliation | |
FROM dating, choices | |
LIMIT 1 | |
-- Works: | |
SELECT dating.*, choices.choice as affiliation | |
FROM dating, choices | |
WHERE dating.traditional = choices.id AND choices.cat = "trad" | |
LIMIT 1 | |
-- Does return something: | |
SELECT dating.*, | |
CASE WHEN true THEN choices.choice END as affiliation | |
FROM dating, choices | |
LIMIT 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment