sql - unrelated data showing in the result(And,OR condition)? -


this query: select top 10000 [reason_text]       ,[ps1]       ,[ps2]       ,[ps3]       ,[ps4]       ,[ps5]       samsung.[dbo].['newlp'] (       reason_text = 'not' or    reason_text = 'in' or    reason_text = 'back'       )  , ps1 = 'u'  , ps2 = 'u' or ps2 = ''  , ps3 = 'u' or ps3 = ''  , ps4 = 'u' or ps4 = ''  , ps5 = 'u' or ps5 = '' 

so clause should have 3 values , ps1 should have 'u' value , ps2 should have 'u' or null , rest of ps's(ps3,ps4,ps5).

the result i'm getting, first 2 ps's correct starting third 'and' ,which ps3 it's condition somehow ignored?!?

here result:

enter image description here

i need return selected ones(red rectangle around them). part of code wrong. i've tried every way nothing returned result need. tried code condition nothing showed.

 , ps1 = 'u'  , ps2 <> 'p'  , ps3 <> 'p'  , ps4 <> 'p'  , ps5 <> 'p' 

appreciate help.

taking reason_text values previous question , looking @ expected result comes mind:

select top 10000 [reason_text]       ,[ps1]       ,[ps2]       ,[ps3]       ,[ps4]       ,[ps5]     samsung.[dbo].['newlp'] (       reason_text = 'parts not available (asc)' or    reason_text = 'parts in transit (samsung)' or    reason_text = 'parts ordered (samsung)'       ) ,   ps1 = 'u'  ,   ( ps2 = 'u' or ps2 null ) ,   ( ps3 = 'u' or ps3 null ) ,   ( ps4 = 'u' or ps4 null ) ,   ( ps5 = 'u' or ps5 null ) 

namely, need check nulls instead of empty strings.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -