In MySQL is it very bad to do this:
SELECT ... WHERE foo IN ('bar')
instead of this...
SELECT ... WHERE foo = 'bar'
...given that this dynamically generated WHERE clause is also likely to be
SELECT ... WHERE foo IN ('bar', 'baz', 'buz')
In MySQL is it very bad to do this:
SELECT ... WHERE foo IN ('bar')
instead of this...
SELECT ... WHERE foo = 'bar'
...given that this dynamically generated WHERE clause is also likely to be
SELECT ... WHERE foo IN ('bar', 'baz', 'buz')
I'm not sure that I would worry about this.
However, because it's dynamically generated you could always do a test to see how many values you have before building the where clause.
It is much better to use, for SQL query optimization and best practices:
WHERE foo = 'bar' OR foo = 'baz'
than:
WHERE foo IN ('bar', 'baz')
Regards
foo = 'bar' OR foo = 'baz', but i don't think that changes something in performance at all