sql - QUERY WHERE BOTH FIELDS DON'T CONTAIN SOMETHING -


i want query data both phone1 , phone2 codes don't contain word 'mobile'. tried , and or statements not working when 'mobile' exists in 1 of fields.

    select ordcon.* pl00.dbo.ordhdr inner join pl00.dbo.ordhdrx on ordhdrx.order_no = ordhdr.order_no                                inner join pl00.dbo.schedule on schedule.id_val = ordhdr.order_no                               left outer join pl00.dbo.ordcon on ordcon.order_no = ordhdr.order_no ordhdr.rspns_code = 'txtb4' , (schedule.[date] >= convert(varchar(10), getdate(), 101))  , (not ordcon.phone1code = 'mobile'  or not ordcon.phone2 = 'mobile') 

the logic want is:

and (ordcon.phone1code <> 'mobile' , ordcon.phone2 <> 'mobile') 

or, assuming neither null:

and 'mobile' not in (ordcon.phone1code, ordcon.phone2) 

are sure second variable not ordcon.phone2code rather ordcon.phone2? suspect correct logic:

and (ordcon.phone1code <> 'mobile' , ordcon.phone2code <> 'mobile') 

Comments