2014-05-07 26 views
-1

我正在尝试使用PHP查询MSSQL表,它将查找具有不等于某个值的列的行。我目前正在使用这个如何使PHP/SQL查询选择列不等于变量的行

$selecting6 = "select * from used_trailers1 where photo1='".$picature2."' or photo='".$picature2."' or name='".$picature2."' or photo2='".$picature2."' or photo3='".$picature2."' or photo4='".$picature2."' and Orderid isnot '".$id."'"; 

无济于事,这个代码是行不通的。

什么正确的代码可以用来选择不具有值$id的行?

谢谢你的帮助。所有的帮助表示赞赏。

回答

1

试试这个

$selecting6 = "select * from used_trailers1 where (photo1='".$picature2."' or photo='".$picature2."' or name='".$picature2."' or photo2='".$picature2."' or photo3='".$picature2."' or photo4='".$picature2."') and Orderid !='".$id."'"; 
+0

我接受你的答案,因为我第一次使用它,它的工作原理。 – Kelsey

+0

@凯尔西很高兴你的问题修复了 – shatheesh