sql - Take away the EXISTS but leave in the switch -


how can modify final script have exclusions switch? not want use exists in final script:

select myfield = 'x' #data union select myfield = 'y' union select myfield = 'z' union select myfield = 'j' union select myfield = 'q' union select myfield = null;  select myfield = 'j' #exclusions union  select myfield = 'q' union select myfield = null;   declare @showall tinyint = 1; -->>exceptions "switch" turned on data returned select *   #data d  @showall = 1 or         (        exists          (          select d.myfield           except          select myfield #exclusions          )        );  --can simplify , rid of exists still include switch based on @showall ?  select *   #data d        except        select myfield #exclusions; 

select *   #data d        except        select myfield #exclusions @showall <> 1; 

http://sqlfiddle.com/#!6/d41d8/3125


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -