简体   繁体   English

MySQL根据某些条件选择某些字段

[英]Mysql selecting some field according to some condition

id  price   tax item    discount
1   500     15  100     0
2   0       15  200     1
3   100     15  500     0
4   0       15  300     0
5   1000    15  88      0
6   0       15  190     1
7   0       15  120     0

Select All if both price and discount or not equal to zero. 如果价格折扣均不等于零,则选择全部。

I don't want to select if the value of price and discount both are zero in mysql 我不想选择在MySQL中价格和折扣的值是否均为零

Not to select only if price and isDiscount both are zero... (only one case) 仅在price和isDiscount都为零时才选择...(仅一种情况)

Price   IsDiscount  Select
1       1           Yes
!0      0           yes
0       1           Yes
0       0           no

I might be missing something here, ...but isn't it as simple as 我可能在这里错过了一些东西,但不是那么简单

SELECT
  id,tax,...
FROM
  tablename
WHERE
   price!=0
   OR discount!=0

?

Here is your simple answer. 这是您的简单答案。 the query is as follows : 查询如下:

select * from orders WHERE price+discount > 0 

从价格表+折扣中选择* from_your_table

从表名WHERE(价格> 0)或(折扣> 0)或(折扣> 0和价格> 0)中选择SELECT ID,TAX,...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM