Multiple OR Clauses in MySQL

后端 未结 7 1464
陌清茗
陌清茗 2020-12-06 05:22

I\'m trying to grab content where id = 3 OR id = 9 OR id = 100... Keep in mind, I can have a few hundred of these ids.

What is the most efficient way to write my q

7条回答
  •  甜味超标
    2020-12-06 05:40

    You may want to use the IN() function:

    ... WHERE id IN (3, 9, 100);
    

    The IN() function syntax:

    expr IN (value,...)

    Check whether a value is within a set of values ...

    Returns 1 if expr is equal to any of the values in the IN list, else returns 0.

提交回复
热议问题