except condition in mysql query..

前端 未结 1 743
孤独总比滥情好
孤独总比滥情好 2021-01-29 01:50

i have table with following structure,

name (type: TEXT)
price (type: INT)
color (type: TEXT)
vehicletype (type: TEXT) eg. SEDAN/SUV 

now i w

相关标签:
1条回答
  • 2021-01-29 02:14
    SELECT name, price, color, vehicletype FROM carrecords WHERE
    -- black sedans up to 10k
    (vehicletype = 'SEDAN' AND color  = 'black' AND price <= 10000)
    -- red or white sedans up to 8k
    OR (vehicletype = 'SEDAN' AND color IN('red','white') AND price <= 8000 )
    -- black SUV up to 15k
    OR (vehicletype = 'SUV' AND color  = 'black' AND price <= 15000)
    -- non-black SUV up to 14k
    OR (vehicletype = 'SUV' AND color  != 'black' AND price <= 14000)
    -- any other vehicle up to 7k
    OR (price <= 7000)
    ORDER BY price ASC  
    
    0 讨论(0)
提交回复
热议问题