[thelist] ASP.NET: UNION query not returning expected results

Joel D Canfield joel at streamliine.com
Thu Sep 27 21:33:47 CDT 2007


>  WHERE E.OfficeID IS NULL OR E.id = 57
> 
>                           ^^^^^^^^^^^^

The '57' isn't really hard-coded; that's just my example for the fact
that it works in the query analyzer.

.NET is going to apply a filter of 'E.id = whatever the id is in the
querystring' *after* the query has run.

So, 'or' logic won't work. Select to your heart's content, and then pile
'E.id = whatever' and you've nuked all the options where E.id !=
whatever.

I need either a completely different approach, or a single query that
selects all the offices not currently assigned to an employee, plus the
one assigned to the employee we're currently editing.



More information about the thelist mailing list