sql - Null user input on subquery criteria -


i'm relatively new sql , trying design query database of 3 tables created (a, b, , c). query allowing user input 2 parameters (date , line) table records returned if user leaves line input blank. works great.

now problem have included 2 subqueries well. these querying tables b , c respectively shared parameter inputs first query. can't results show if try allow null user input return records.

  1. the statement main query works:

    having (((a.line)=[enter line]) , ((a.day)>=[start date] , (a.day)<=[end date])) or (((a.day)>=[start date] , (a.day)<=[end date]) , (([a].[line] [enter line]) null)) 
  2. trying same thing using or having on subqueries not work:

    where (b.day)>=[start date] , (b.day)<=[end date] , b.line=[enter line] or (((b.day)>=[start date] , (b.day)<=[end date]) , ([b].[line] [enter line]) null)) 

the subqueries work fine , return correct results if remove or statement tries account null input, unable return records when user input blank.

i appreciate help! realize messy , inefficient.

in clause:

where (b.day)>=[start date]    , (b.day)<=[end date]    , b.line=[enter line]     or (...) 

you combining and or in same statement without using parenthesis explicitly set logical precedence. try this:

where (    (b.day)>=[start date]         , (b.day)<=[end date]         , b.line=[enter line]        ) or (...) 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -