Is this ever usefull/or ever going to help/why would someone do this inner join A1 on B1 column identity and then use A1.identity = B1.identity in where clause

  • Ok guys,

    Sorry for the long title but I kind of want to lift my own confusion about this one.

    I've been tasked to clean up/improve some stored procedures in one of our product databases,now this procedure is not from my hand and has been around for longer then I've graduated from college.

    Simplified it's this

    select A1.ID,A1.Quantity,(B1.Value/A1.Quantity) as ValuePerUnit

    from A1

    inner join B1 on A1.identity = B1.identity

    where A1.identity = B1.identity

    Why would anyone do this

  • No good reason. Probably it started as

    select A1.ID,A1.Quantity,(B1.Value/A1.Quantity) as ValuePerUnit

    from A1, B1

    where A1.identity = B1.identity

    and then changed to use a JOIN and the where clause never removed.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Yeah, I'm considering this as well, but I has nobody before me noticed this, as far as the documentation goes this query was created somewhere in 2007 and last changed in 2011.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply