Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 OR statement

Author  Topic 

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2012-01-01 : 02:03:46
Hello, good day.

If I want to publish the result as depart from parkingA or parkingB or parkingC and arrive from parkingA or parkingB or parkingC where this 3 destination depart or arrive, i will not charge the parking fee.

So, should i select like this?

select parking.depart in ('pA','pB','pC')
OR
parking.arrive in ('pA','pB','pC')

im not getting the result either depart or arrive from this 3 station. i get result which depart or arrive from other station as well pD,pE,pF,etc...

Is my query wrong?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-01 : 02:08:53
[code]
select *
from tablename here
where parking.depart in ('pA','pB','pC')
OR
parking.arrive in ('pA','pB','pC')
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2012-01-01 : 02:11:59
Thats what i did with my query, but it publish other parking station as well.
Go to Top of Page

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2012-01-01 : 02:27:33
it works on AND statement.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-01-01 : 02:32:30
shouldn't it be a AND condition ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2012-01-01 : 02:34:42
i tried OR condition but is not working. when i use AND statement is working, it only give the 3 station.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-02 : 12:16:33
quote:
Originally posted by peace

i tried OR condition but is not working. when i use AND statement is working, it only give the 3 station.


sorry your explanation doesnt make sense
can you show with help of sample data what you meant?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -