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.
| Author |
Topic |
|
Sarakumar
Posting Yak Master
108 Posts |
Posted - 2009-04-15 : 21:55:38
|
| Hai, To clarify with u people, i have written a query, in which i have used multiple tables, using the join condition.i have where condition also for that query. now my quetion is , which one take the precedence..join or Where condition.b'coz in the where condition i have something like where (id =1 and isdel = 0 ) or id=5.assuming that all the time, the record for id =5 will be returned as it is in OR condition but it is not happening..when i investigated the query i realised one of my inner join, eliminate this record before i apply the where condition..is the behaviour correct.. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
kunal.mehta
Yak Posting Veteran
83 Posts |
Posted - 2009-04-16 : 03:06:57
|
Hi,This is working for medeclare @table1 table (id int,price float ) insert into @table1 values(1,841.75) insert into @table1 values(2,841.75) insert into @table1 values(3,842) insert into @table1 values(4,842) insert into @table1 values(5,842) select * from @table1 where (id=1 and price=841.75) or id = 5Kunal |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-16 : 03:10:51
|
It depends on the Query Optimizer.One factor is the number of records in the JOINed tables. A large number would require a hash join (which is very efficient but costly since hash values need to be built). The Optimizer may consider evaluating the WHERE first to bring down the number of records to JOIN. And then maybe the JOIN can be of type NESTED LOOP or even MERGE.So, it depends on a number of factors. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
Sarakumar
Posting Yak Master
108 Posts |
Posted - 2009-04-16 : 03:14:34
|
| ok friends thanks. i have used the union query to do my requirement |
 |
|
|
|
|
|
|
|