Home » SQL & PL/SQL » SQL & PL/SQL » SELECT QUERY
SELECT QUERY [message #239060] Mon, 21 May 2007 06:57 Go to next message
vamsikgummadi
Messages: 62
Registered: April 2006
Location: United States, MI
Member
Hello friends,
I have a table as follows:

From EmailId EmailId Scrap Scrap date Scrap time
abc@gmail.com 123@gmail.com How are u? 15-10-2006 4AM
123@gmail.com abc@gmail.com Fine! Thank you. 15-10-2006 5AM
abc@gmail.com 123@gmail.com Where are U now? 15-10-2006 6AM
123@gamil.com abc@gmail.com HYD 15-10-2006 7AM
abc@gmail.com 123@gmail.com I am in VSP 15-10-2006 8AM

Now, I want to retrieve data with following conditions

FromEmailId='abc@gmail.com' and EmailId='123@gmail.com'

AND

FROMEmailId='123@gmail.com' and EmailId='abc@gmail.com'.


How Can I retrieve the data using a single query using a JOIN or a VIEW .

With Regards,
Vamsi K Gummadi.
Re: SELECT QUERY [message #239063 is a reply to message #239060] Mon, 21 May 2007 07:06 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
The two conditions you specify contradict each other. Don't you mean:

WHERE (     FromEmailId='abc@gmail.com' 
        AND EmailId    ='123@gmail.com'
      )

OR    (     FromEmailId='123@gmail.com' 
        AND EmailId='abc@gmail.com'
      )



MHE
Re: SELECT QUERY [message #239064 is a reply to message #239060] Mon, 21 May 2007 07:06 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
combine your conditions with OR.
Re: SELECT QUERY [message #239065 is a reply to message #239060] Mon, 21 May 2007 07:06 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
You don't need to use an extra join or a view. You just need brackets.
SELECT <fields>
FROM   <table>
WHERE (FromEmailId='abc@gmail.com' and EmailId='123@gmail.com')
OR    (FROMEmailId='123@gmail.com' and EmailId='abc@gmail.com')


{drat - FAR too slow}

[Updated on: Mon, 21 May 2007 07:06]

Report message to a moderator

Re: SELECT QUERY [message #239087 is a reply to message #239060] Mon, 21 May 2007 08:02 Go to previous message
vamsikgummadi
Messages: 62
Registered: April 2006
Location: United States, MI
Member
Dear Friends,

Thank you, your hints and suggestions helped me to sort out the problem with much ease.

Actually I am using the brakets wrongly.

Thank you for the correction made and helping me .

With regards,
Vamsi K Gummadi. Laughing
Previous Topic: database samples ???
Next Topic: Loading missing data from one table to another
Goto Forum:
  


Current Time: Wed Dec 07 04:55:19 CST 2016

Total time taken to generate the page: 0.05952 seconds