Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter rows based on a value of a column

Suppose I have a table:

-----------------
ID | PARTY | NAME
-----------------
1  | IND   | ABC
2  | IND   | DEF
3  | CUST  | GHI
4  | CUST  | JKL
5  | IND   | MNO
-----------------

I want to filter rows based on NAME whose PARTY = 'IND'. And all other rows should be present in the result set.

For example:

if i want to filter on NAME = 'ABC' then data returned should be something like this:

-----------------
ID | PARTY | NAME
-----------------
1  | IND   | ABC
3  | CUST  | GHI
4  | CUST  | JKL
-----------------

I have tried it using where clause but not getting the right result. Any help would be appreciated.

P.S. I'm working in Oracle 10g.

like image 678
HashimR Avatar asked Dec 29 '25 03:12

HashimR


1 Answers

You can simply do;

SELECT * 
FROM Table1 
WHERE Name='ABC' OR Party<>'IND';

An SQLfiddle to test with.

like image 80
Joachim Isaksson Avatar answered Dec 30 '25 17:12

Joachim Isaksson