Select * from RG_TAB where CMCode = 4 and CMCode = 5
This query not giving me any result but
if u use this clause (and operator) it means two condition must be available. if just one condition only (ex CMCode=4) then this command didn't give result. so CMcode = 4 & CMcode = 5 must be available to get result.
Select * from RG_TAB where CMCode = 4 Or CMCode = 5
is giving me result.
This clause will give result if one of condition available or two condition available. so you don't needed two condition to give a result, one condition can give result.
Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
yes it is, use "where cmcode = 4 or cmcode = 5" which will give you all the rows where cmcode is either 4 or 5 (it can never be both at the same time, which is why your original query gave no results).
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
yes, as jwenting said. it can never be both at the same time.
Sawamura
Junior Poster in Training
69 posts since Nov 2007
Reputation Points: 55
Solved Threads: 6
i suggest to use or operand in query, don't use and.
Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
An alternative which you may see commonly is instead of using multiple references to a field with 'or' is to write something like
Select * from RG_TAB where CMCode in ( 4, 5 )
You can imagine when you have 5 or 6 possible values that this is much shorter and easier to read.
Nige
Nige Ridd
Junior Poster in Training
52 posts since Nov 2007
Reputation Points: 13
Solved Threads: 9
AND means all the conditon must satisfy.
OR means any of the condition should satisfy.
debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434