SQL multiple columns in IN clause

后端 未结 6 2008
情书的邮戳
情书的邮戳 2020-11-27 04:15

If we need to query a table based on some set of values for a given column, we can simply use the IN clause.

But if query need to be performed based on multiple col

6条回答
  •  不知归路
    2020-11-27 05:00

    Determine whether the list of names is different with each query or reused. If it is reused, it belongs to the database.

    Even if it is unique with each query, it may be useful to load it to a temporary table (#table syntax) for performance reasons - in that case you will be able to avoid recompilation of a complex query.

    If the maximum number of names is fixed, you should use a parametrized query.

    However, if none of the above cases applies, I would go with inlining the names in the query as in your approach #1.

提交回复
热议问题