Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Using Exotic Joins in SQL Part 1


Using Exotic Joins in SQL Part 1

Author
Message
jeffrey yao
jeffrey yao
Old Hand
Old Hand (320 reputation)Old Hand (320 reputation)Old Hand (320 reputation)Old Hand (320 reputation)Old Hand (320 reputation)Old Hand (320 reputation)Old Hand (320 reputation)Old Hand (320 reputation)

Group: General Forum Members
Points: 320 Visits: 874

I think you can use the following sql to do your work

select * from My_Table

where col_date between isnull(@Start_Date, '1900-01-01') and isnull(@End_Date, '2999-01-01')

Assume your real date is no earlier than '1900-01-01' and no later than '2999-01-01')





YSLGuru
YSLGuru
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1122 Visits: 1665

David,

You say that dropping the support for the WHERE clause is breaking away from the ANSI standard. It is the ANSI standard that has pshed the move to using the FROM clause for Joins and not the WHERE clause. Based on that how would this move by Microsoft be considered a move away from the ANSI standard? Even if the latest standard allows for joins in the FROM and WHERE clause the fact that the preferred method of joins is in the FROM clause I would think that sticking with usisng the WHERE clause would actually be a move away from the ANSI standard.

PLease understand that I am not trying to sound negative or attack your comment, I know personally how emails and postings are poor at properly conveying emotions. I am merely trying to understand why you feel this way and try to find out if maybe I have missed something or have improperly understood the ANSI standard.

Thanks

Ed



Kindest Regards,

Just say No to Facebook!
Calvin Lawson
Calvin Lawson
SSChasing Mays
SSChasing Mays (630 reputation)SSChasing Mays (630 reputation)SSChasing Mays (630 reputation)SSChasing Mays (630 reputation)SSChasing Mays (630 reputation)SSChasing Mays (630 reputation)SSChasing Mays (630 reputation)SSChasing Mays (630 reputation)

Group: General Forum Members
Points: 630 Visits: 102
quote

BETWEEN is purely simpler to read. There is no specific engine enhancements that make BETWEEN any faster.

2cents more..."Between" is not ANSI 92 standard, so using < and > is more portable.

Signature is NULL
ROhit Shrivastava
ROhit Shrivastava
Grasshopper
Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)

Group: General Forum Members
Points: 14 Visits: 20

Hi

You can write query like this:

suppose say you are passing two parameters name @StartDate and @EndDate and you column name in table is TransDate

TransDate BETWEEN ISNULL(@StartDate, TransDate) AND ISNULL(@EndDate, TransDate)

Rohit


John Q Public-431253
John Q Public-431253
SSC Rookie
SSC Rookie (38 reputation)SSC Rookie (38 reputation)SSC Rookie (38 reputation)SSC Rookie (38 reputation)SSC Rookie (38 reputation)SSC Rookie (38 reputation)SSC Rookie (38 reputation)SSC Rookie (38 reputation)

Group: General Forum Members
Points: 38 Visits: 417
One of the poorest articles I have read in the long time. Theta join is by no means an exotic operator. Set equality and set containment join is. Google "relational division"
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search