简体   繁体   中英

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

Not to select only if price and isDiscount both are zero... (only one case)

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,...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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