I am designing a stored procedure to return results from a search.
I need all apartments returned that has a specific zipcode..
The select should do what this does:
select * from tbl_houses
where
(
(zip_code in (10000,20000,30000,40000))
or
(zip_code > 50000 and zip_code < 60000)
)
In other words. I want a stored procedure which can both take a zip_code range and series of zip_codes.
Anyone know an elegant way of doing this?
My current solutions are ugly as xxxx.
Cheers
Mathias
You can use a Split Table-value function for this:
Then you can use it on your stored procedure, maybe with another parameter indicating if its a range or a list: