Home » Developer & Programmer » Forms » Conditions on same column but two different values (oracle 9i,forms 6i)
Conditions on same column but two different values [message #391937] Sat, 14 March 2009 15:15 Go to next message
mohaninforakle
Messages: 55
Registered: January 2009
Member
hi experts,


Am have a requirement that my query only return values from table
which contains a column it should match more than one different value.Example

Table name student
Colname studentno

colname studentno is my column of table student,now am executing a query like below,

select studentno from student where studentno='1' and studentno='2'

both student no 1 and 2 if exist then only my query should return value other wise not.I tried with in statement but it return value if either value exists.Please help me on this.
Re: Conditions on same column but two different values [message #392063 is a reply to message #391937] Mon, 16 March 2009 04:22 Go to previous messageGo to next message
cookiemonster
Messages: 12422
Registered: September 2008
Location: Rainy Manchester
Senior Member
That would be two different rows you're checking.
If you want your query to reference two different rows in the same table you need to have two instances of the table in your FROM clause.
i.e.
FROM student s1, student s2


See if you can work out the rest from here.
Re: Conditions on same column but two different values [message #392152 is a reply to message #391937] Mon, 16 March 2009 11:35 Go to previous messageGo to next message
mohaninforakle
Messages: 55
Registered: January 2009
Member
thanks for your reply ,but the result displayed in two columns i want it to be displayed in two rows.Please help me more on this.
Re: Conditions on same column but two different values [message #392154 is a reply to message #391937] Mon, 16 March 2009 11:53 Go to previous messageGo to next message
cookiemonster
Messages: 12422
Registered: September 2008
Location: Rainy Manchester
Senior Member
what exactly do you want the output to be?
Re: Conditions on same column but two different values [message #393066 is a reply to message #391937] Fri, 20 March 2009 04:02 Go to previous messageGo to next message
manu_jariwala
Messages: 20
Registered: August 2005
Location: Surat
Junior Member

Hi,

Can we use function or Cursor for this problem?

Bye
Re: Conditions on same column but two different values [message #393097 is a reply to message #393066] Fri, 20 March 2009 05:39 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You may try and see.
Re: Conditions on same column but two different values [message #393118 is a reply to message #391937] Fri, 20 March 2009 06:33 Go to previous messageGo to next message
muhammad.sufyan
Messages: 1
Registered: February 2007
Location: KARACHI-PAKISTAN
Junior Member

dear hi, if i understand what you want.
pls. use it
select studentno from student where studentno='1' or studentno='2'

thanks
sufyan
msufyan08217@hotmail.com

Re: Conditions on same column but two different values [message #393121 is a reply to message #391937] Fri, 20 March 2009 06:43 Go to previous messageGo to next message
cookiemonster
Messages: 12422
Registered: September 2008
Location: Rainy Manchester
Senior Member
That's not going to work.

mohaninforakle wrote on Sat, 14 March 2009 20:15
both student no 1 and 2 if exist then only my query should return value other wise not.


He wants to get results if both rows exist and nothing otherwise.
Your query will give results if either exist.
Re: Conditions on same column but two different values [message #393241 is a reply to message #393121] Fri, 20 March 2009 15:58 Go to previous message
nastyjillu
Messages: 211
Registered: February 2009
Senior Member
hi mohan,
can you be more clear?? are you working on forms or just sql query?

if you are working on forms then send image of it.
Previous Topic: problem
Next Topic: Challenging Task for all gurus
Goto Forum:
  


Current Time: Fri Dec 09 19:21:53 CST 2016

Total time taken to generate the page: 0.12520 seconds