•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Oracle section within the Web Development category of DaniWeb, a massive community of 422,796 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,330 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Oracle advertiser: Programming Forums
Views: 1662 | Replies: 9 | Solved
![]() |
Hi
i want to select the values from my table where a column must contains some value. So i wrote this
Select * from RG_TAB where CMCode = 4 and CMCode = 5
This query not giving me any result but
Select * from RG_TAB where CMCode = 4 Or CMCode = 5
is giving me result.
I am confused. What is happening. What should be the query?
Thanks and regards,
sbv
i want to select the values from my table where a column must contains some value. So i wrote this
Select * from RG_TAB where CMCode = 4 and CMCode = 5
This query not giving me any result but
Select * from RG_TAB where CMCode = 4 Or CMCode = 5
is giving me result.
I am confused. What is happening. What should be the query?
Thanks and regards,
sbv
•
•
Join Date: Nov 2007
Location: � Jogja �
Posts: 2,584
Reputation:
Rep Power: 11
Solved Threads: 235
•
•
•
•
Select * from RG_TAB where CMCode = 4 and CMCode = 5
This query not giving me any result but
•
•
•
•
Select * from RG_TAB where CMCode = 4 Or CMCode = 5
is giving me result.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
•
•
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.
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.
Hi
Thanks for reply.
My Table contents are as follows.....
RID MasterVal CMCode
-------------------------------------
1 Cricket 4
2 Marketing 5
3 bla bla
Now here from my table i want to select records where CMCode is 4 and 5. So is my query is wrong!!
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation:
Rep Power: 18
Solved Threads: 197
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).
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
•
•
Join Date: Feb 2008
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 2
•
•
•
•
Hi
i want to select the values from my table where a column must contains some value. So i wrote this
Select * from RG_TAB where CMCode = 4 and CMCode = 5
This query not giving me any result but
Select * from RG_TAB where CMCode = 4 Or CMCode = 5
is giving me result.
I am confused. What is happening. What should be the query?
Thanks and regards,
sbv
hi
use this query - Select * from RG_TAB where CMCode = 4 Or CMCode = 5
•
•
Join Date: Nov 2007
Location: � Jogja �
Posts: 2,584
Reputation:
Rep Power: 11
Solved Threads: 235
i suggest to use or operand in query, don't use and.
Last edited by Jx_Man : Feb 9th, 2008 at 1:23 pm.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
•
•
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
hi
thanks to all.
what i need is gained by using the query of IN and Not In.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Oracle Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Retrieve email I sent to the wrong person (Web Browsers)
- Ram voltage wrong?? (Motherboards, CPUs and RAM)
- Am I going about this the wrong way (IT Technologies and Trends)
- My CD-RW plays but won't burn. What could be wrong?? Help Please? (Storage)
- wats wrong with imesh??? (Windows NT / 2000 / XP / 2003)
Other Threads in the Oracle Forum
- Previous Thread: Toad
- Next Thread: connecting toad with oracle



Linear Mode