views:

33

answers:

2

A field in my table can have arbitrary strings. On the UI, there is a drop down having options like

All, Value1, Value2

And the results were filtered by the selected option value. So far this is easy and adding new filters to the UI is not a problem. Needs no changes in my stored procedure. Now I want to have an "Others" option here as well, which will return rows not having the column value as Value1 or Value2.

Apparently this will require a "not in" operator in my query, and will make maintenance difficult, as the list of values is likely to change

Any suggestions, design tips?

+2  A: 

If your options table could have an additional column called IsOther then your query could simply be WHERE IsOther = 1 instead of using a NOT IN.

Daniel Renshaw
+2  A: 

Make a separate stored procedure for others case and call it when the selected option is others. Pass the contents of the list as input to the procedure: by this way, you need to update the list only at one place.

Amarghosh