Statement return NULL

  • Good morning All,

    Is there a reason this statement is returning NULL?

    WHERE tbl_Assembly_Holds.WorkOrder = LEFT(tbl_Assembly_Production.WorkOrder, 5) AND tbl_Assembly_Production.dateProd Between '8/3/2009' AND '8/31/2009' AND tlkp_Defects.Defect_Title = 'Jar To Cover Leak' AND tlkp_Item.Model = 'LCT 1680' AND tlkp_Item.Model LIKE '%[X]%'

  • Without access to your database, I can't be certain, but most likely, because there aren't any rows that satisfy all your criteria.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • kabaari (9/2/2009)


    Good morning All,

    Is there a reason this statement is returning NULL?

    WHERE tbl_Assembly_Holds.WorkOrder = LEFT(tbl_Assembly_Production.WorkOrder, 5) AND tbl_Assembly_Production.dateProd Between '8/3/2009' AND '8/31/2009' AND tlkp_Defects.Defect_Title = 'Jar To Cover Leak' AND tlkp_Item.Model = 'LCT 1680' AND tlkp_Item.Model LIKE '%[X]%'

    I would assume becasue of this part of your where clause:

    tlkp_Item.Model = 'LCT 1680' AND tlkp_Item.Model LIKE '%[X]%'

    Sorta impossible, no? 🙂

  • Maybe it should look something more like:

    AND (tlkp_Item.Model = 'LCT 1680' OR tlkp_Item.Model LIKE '%[X]%')

    Or completely eliminate the second Model condition.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

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

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