Reputation: 597
I'd like to use the SQL LIKE or CONTAINS operator with multiple arguments. Is there a way to do this efficiently, or does each instance of LIKE have to be separated by OR?
WHEN postal_zip_code_permanent like ('A', 'B', 'C', 'E', 'G', 'H', 'J', 'R', 'S', 'T', 'V', 'X', 'Y') THEN 'Canada, outside Ontario'
Upvotes: 0
Views: 764
Reputation: 16726
In your simple case you can use IN
instead of LIKE
WHEN postal_zip_code_permanent IN ('A', 'B', 'C', 'E', 'G', 'H', 'J', 'R', 'S', 'T', 'V', 'X', 'Y') THEN 'Canada, outside Ontario'
If you really need LIKE
, you need to write
WHEN postal_zip_code_permanent LIKE 'A%' OR postal_zip_code_permanent LIKE 'B%' THEN ...
Upvotes: 4