Stack Exchange
why i am getting "no data found" error in oracle live even if i have the data that satisfying my conditions?
INSERT INTO PRODUCTS(PNO,PNAME,COLOR,SALE_PRICE) 
VALUES(1001,'BOOK','PINK',1500);

INSERT INTO PRODUCTS(PNO,PNAME,COLOR,SALE_PRICE) 
VALUES(1002,'TABLE','BLUE',3500);

INSERT INTO PRODUCTS(PNO,PNAME,COLOR,SALE_PRICE) 
VALUES(1003,'COVER','BLACK',1800);

INSERT INTO PRODUCTS(PNO,PNAME,COLOR,SALE_PRICE) 
VALUES(1004,'PANT','WHITE',2500);

INSERT INTO PRODUCTS(PNO,PNAME,COLOR,SALE_PRICE) 
VALUES(1005,'RIBBON','RED',1500);

INSERT INTO PRODUCTS(PNO,PNAME,COLOR,SALE_PRICE) 
VALUES(1006,'RING','BLUE',3000);

INSERT INTO PRODUCTS(PNO,PNAME,COLOR,SALE_PRICE) 
VALUES(1007,'CUP','RED',2500);

INSERT INTO PRODUCTS(PNO,PNAME,COLOR,SALE_PRICE) 
VALUES(1008,'SHIRT','PINK',3000);

//query
SELECT PNO, PNAME
FROM PRODUCTS
WHERE (COLOR = 'PINK') AND (COLOR = 'RED')
AND  SALE_PRICE < 2000;


Please add the creat table for PRODUCTS

There is no single row that satiisfies both conditions color='pink' and color='red'. The conditions in the WHERE clause are evaluated for each row. We know that if color='pink' evaluates to TRUE, then color='red' will evaluate to FALSE, and we know "true AND false" evaluates to "false". That's why no rows are being returned. (When converting the AND to OR, we need to be aware that AND has a higher order of precedence than OR, which means we are going to need to add some parens, or repeat the condition on sale_price.)

i wanted both true and also their sale price should less than 2000.

You cannot have COLOR = 'PINK' and COLOR = 'RED', use OR instead 
SELECT PNO, PNAME FROM PRODUCTS WHERE ((COLOR = 'PINK') OR (COLOR = 'RED')) AND SALE_PRICE < 2000;
You can also use IN clause also like this
SELECT PNO, PNAME FROM PRODUCTS WHERE COLOR IN ('PINK', 'RED') AND SALE_PRICE < 2000;

It's working thanks for the help this will solve another problem

The reason this is happening is because you don't have any entries with PINK AND RED. Use OR instead.
//query
SELECT PNO, PNAME
FROM PRODUCTS
WHERE (COLOR = 'PINK') OR (COLOR = 'RED')
AND  SALE_PRICE < 2000;

This next part is just to quickly show you that you have an option when adding multiple inserts:
INSERT INTO PRODUCTS(PNO,PNAME,COLOR,SALE_PRICE) 
VALUES
(1001,'BOOK','PINK',1500),
(1002,'TABLE','BLUE',3500),
(1003,'COVER','BLACK',1800),
(1004,'PANT','WHITE',2500),
(1005,'RIBBON','RED',1500),
(1006,'RING','BLUE',3000),
(1007,'CUP','RED',2500),
(1008,'SHIRT','PINK',3000);


Your insert query is wrong there must be only one values

oh. i see what you meant, VALUES(), not values. fixing/thanks

beware the order of precedence of AND and OR. The syntax shown in this answer has the potential to return rows with color='pink' with any value of sale_price. We can use parens to override the order of precedence, or repeat the condition on sale_price, or we can use IN ('pink','red'),

it's working but because of OR condition I am getting extra detail which for a SHIRT which is not satisfying my condition.

You have a pink shirt in your data though. Did you just need to add another filter in your WHERE?

@Mech: the syntax in this answer is not checking sale_price when color is pink, i.e. its equivalent to color='pink' OR ( color='red' AND sale_price<2000 )
