2013-06-12 159 views
2

是否有可能做這樣的OR語句?你如何做一個MySQL WHERE東西='東西'或...(PHP)

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 

回答

6

使用IN

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

AHHHHHH ...... COOL!我會試一試.. hangon! – Jimmyt1988

+0

哎呀,忘了說它完美的作品。乾杯! – Jimmyt1988

0

使用與IN

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