Skip to content
Advertisement

sqlite select hard coded text given a matching “or” condition

I have a table like this:

I am querying for column values whose length is 0 using a statement like this:

SELECT key FROM table WHERE length(c1) = 0 OR length(c2) = 0 OR ... OR length(cn) = 0;

I’d like to have a text associated with the key indicating which condition lead to the match. so something like

not sure how to do this

Advertisement

Answer

You can use a CASE expression for this. On the other hand, note that in SQLite you can use MIN() to simplify the WHERE clause:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement