If I want to find records where a given field is equal to some value, I use
SELECT * from TableName WHERE FieldName=value;
If I want to select records which match a list of values, I can use
SELECT * from TableName WHERE FieldName IN (value1, value2, ..., valueN);
to avoid having
(edited since seemingly this misled about the purpose of the question)WHERE FieldName = value1 OR FieldName = value2 OR...
Using .eqp on
seems to suggest that when my list contains only one element, the two queries are equivalent.
Is this true?
If so, can I freely use WHERE FieldName IN (...)
and parse values into a comma separated list (avoiding trailing commas, etc) without cost to the query?
It would seem this will greatly simplify coding my queries, but I am surprised that there isn't an additional complexity cost from the IN
operator, regardless of the list being only one element.
Edit: To be clear, I won't use OR
in any case - if I have one value, then previously I had been using the first form (FieldName=value
). If I had several values, I used IN (val1, val2, ...)
. Based on comments, it would seem that I can remove the code I need to use to handle these, and instead search only for IN (value1)
.