Firebird, query in c#, different queries on different values, how to construct and simplify it? -


have checkbox month, checkbox year , following code (pseudo code):

if(month.checked) query = select* tab month=month.text; if(year.checked) query = select* tab year=year.text; if(month.checked , year.checked) query = select * tab month=month.value , year=year.value if(!month.checked , !year.checked) query = select* tab 

so see there 4 different queries. possible faster, in 1 query?

technically make 1 query of this, query gets lot more complex , leads slower queries. unless have compelling reason it, stick separate queries.

something query below trick:

select * tab ? not null , month = ? or ? not null , year = ? or ? null , ? null 

here parameter 1 , 5 indicator if month checked (null means not checked, value means checked), parameter 2 value of month.text, parameter 3 , 6 indicator if year checked , parameter 4 value of year.text.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -