i have table with following structure,
name (type: TEXT)
price (type: INT)
color (type: TEXT)
vehicletype (type: TEXT) eg. SEDAN/SUV
now i want to retrieve (name, price, color, vehicletype) If its a black sedan, I’m ready to pay 10,000, but if its red or white, then no more than 8,000. For any other color I won’t go above 7,000, except if its an SUV, in which case my budget is upto 15,000 for a black one or upto 14,000 for any other color.
i have this query, but it’s not worked,
SELECT name, price, color, vehicletype FROM carrecords WHERE
(vehicletype = 'SEDAN' AND color = 'black' AND price <= 10000) OR
(vehicletype = 'SEDAN' AND color IN('red','white') AND price <= 8000 ) OR
(vehicletype = 'SEDAN' /* here I tried != "SUV" as well - no luck*/ AND color NOT IN('red','white','black') AND price <= 7000) OR
(vehicletype = 'SUV' AND color = 'black' AND price <= 15000) OR
(vehicletype = 'SUV' AND color != 'black' AND price <= 14000)
ORDER BY price ASC
so, is there any solution?
1 Answer