你怎么做一个mysql WHERE something ='something'或者...(PHP)

时间:2013-06-12 10:09:40

标签: mysql sql where

是否可以像这样做一个OR语句?

WHERE pR.projectRelationId = '$id[ 0 ]' OR '$id[ 1 ]' OR '$id[ 2 ]'
AND pR.type = 'yada' AND

或者您是否必须继续重新进行比较:

        WHERE 
            pR.projectRelationId = '$id[ 0 ]' OR 
            pR.projectRelationId = '$id[ 1 ]' OR 
            pR.projectRelationId = '$id[ 2 ]'
            AND
            pR.type = 'yada' AND

2 个答案:

答案 0 :(得分:6)

使用IN

pR.projectRelationId IN ('$id[ 0 ]', '$id[ 1 ]', '$id[ 2 ]')

答案 1 :(得分:0)

IN

一起使用
WHERE pR.projectRelationId IN ('$id[ 0 ]','$id[ 1 ]','$id[ 2 ]') AND pR.type = 'yada' AND