RE: Number Range Query
Dempsey,
If you have a list of values you want, SQL has the IN operator:
SELECT * FROM foo WHERE bar IN (29, 32, 33, 37, 45, 78, 82, 200, 678, 680, 683, 690, 705)
The list can result from a subquery, so if your list is too long to specify as literals, you could create a temporary table, insert all the values you want in it, and then:
SELECT * FROM foo WHERE bar IN (SELECT bar FROM tmptable)
Of course, if the list is somehow derived from the database, you should just use that query directly and avoid the need for temporary tables. This is where the context of what you are doing becomes important -- unless the arbitrary list is truly arbitrary (e.g. user selected), there probably is a better way.
|