I have a table in mysql witch I have to print in mysql:
List only the name and weight of all the parts except the Red parts whose weight is greater than 15.0.
I've been trying to do it but i couldn't.
CREATE TABLE parts (
partNum CHAR(2) NOT NULL,
name CHAR(10) NOT NULL,
colour CHAR(8) NOT NULL,
weight DECIMAL(3,1) NOT NULL,
city VARCHAR(10) NOT NULL,
PRIMARY KEY (partNum)
);
CodePudding user response:
ListSELECTonly thenameand, weight FROMof all thepartsexceptWHERE NOT (the Red partsCOLOUR = 'Red'whoseAND weightis greater than>= 15.0
SELECT name, weight
FROM parts
WHERE NOT ( COLOUR = 'Red' AND weight >= 15.0 );
CodePudding user response:
SELECT `name`, `weight`
FROM `parts`
WHERE NOT ( `colour` = 'Red' AND `weight` > 15 );