0

你能检查一下这个sql查询有什么问题吗

SELECT DISTINCT
   A.a
A.b
FROM tableAA AS A
INNER JOIN(tableBB AS B)
ON(A.a= B.a)
INNER JOIN(tableCC AS C)
ON(A.a = C.a)
INNER JOIN(tableDD AS D)
ON(A.a = D.a)

WHERE 

  B.c = '$selectedtype' AND
  B.d NOT LIKE '%$selection%' AND
  C.e='$selction111' 
OR
    D.c = '$selectedtype' AND
A.d NOT LIKE '%$selection%' AND
    C.e='$selction111' 

我对 OR 条件有疑虑,我在这里想要“where”和“OR”之间的条件为真或低于“OR”的条件为真。

书写方式是否正确?还是有其他写法?

4

1 回答 1

0

您可能正在寻找:

(B.c = '$selectedtype' AND B.d NOT LIKE '%$selection%' AND C.e='$selction111')
OR
(D.c = '$selectedtype' AND A.d NOT LIKE '%$selection%' AND C.e='$selction111')
于 2013-08-19T23:07:45.513 回答