Reputation: 139
This is an example of what I want to do:
I have a table called: TEST
it has two columns: ColA
and ColB
It has the following data:
ColA ColB
---- ----
0 1
0 1
0 3
2 1
2 3
I want to retrieve all values where ColA > 0, except I want to still include rows where ColA = 0 if ColB = 3
Upvotes: 2
Views: 644
Reputation: 11
SELECT * FROM TEST WHERE colA > 0 OR (colA=0 AND colB=3);
Not test yet, but hopefully this should work.
Upvotes: 0
Reputation: 1576
Try This SQL
SELECT * FROM TEST WHERE ColA > 0 OR ( ColA = 0 AND ColB = 3)
It returns the following data
ColA ColB
0 3
2 1
2 3
Hope it helps.
Upvotes: 0
Reputation: 91550
The following should work:
SELECT *
FROM TEST
WHERE ColA > 0 --All rows where ColA > 0
OR (ColA = 0 AND ColB = 3) -- All rows where ColA = 0 AND ColB = 3
Upvotes: 3