Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
sql查询以获取包含所选id的结果_Sql - Fatal编程技术网

sql查询以获取包含所选id的结果

sql查询以获取包含所选id的结果,sql,Sql,我一直在使用sql查询。 我想从单个表中选择产品,但排除所选产品。 我的wp_产品表如下所示 product_id prod_name prod_price prod_rate 1 xyz 100 5 2 pqr 200 6 3 lmn 300 6 我正在尝试执行此查询 select * fro

我一直在使用sql查询。 我想从单个表中选择产品,但排除所选产品。 我的wp_产品表如下所示

product_id   prod_name   prod_price   prod_rate
   1           xyz         100           5
   2           pqr         200           6 
   3           lmn         300           6
我正在尝试执行此查询

select * 
from wp_products 
where product_id <>'1' AND prod_price <=200 OR prod_rate='6'  OR 
          order by product_id DESC 
          LIMIT 4"
从上面的结果中,我希望选择(检查)我在尝试过的查询中使用的所有“或”条件


建议我如何获得此信息。

如果我理解正确,请使用括号:

select * 
from wp_products 
where product_id <>'1' AND 
  (price<=200 OR wheel_size='6'  OR  studs='$studs') 
order by product_id DESC 
选择*
来自wp_产品
其中产品标识“1”和

(price如果我理解正确-只需使用括号:

select * 
from wp_products 
where product_id <>'1' AND 
  (price<=200 OR wheel_size='6'  OR  studs='$studs') 
order by product_id DESC 
选择*
来自wp_产品
其中产品标识“1”和
(价格试试下面的sql

select * from wp_products
where (product_id <>'1') AND (price<=200 OR wheel_size='6' OR studs='$studs') 
order by product_id DESC LIMIT 4
从wp\U产品中选择*
其中(product_id'1')和(price请尝试下面的sql

select * from wp_products
where (product_id <>'1') AND (price<=200 OR wheel_size='6' OR studs='$studs') 
order by product_id DESC LIMIT 4
从wp\U产品中选择*

其中(产品编号“1”)和(价格:是的,我正想要这个。谢谢:是的,我正想要这个。谢谢