searched integer column

searched integer column

am 11.11.2004 07:09:08 von ben h

I have a basic page that returns a resultset of widgets (using an
integer identity field amongst others) that i want to provide a better
search for.

currently i allow the user to seach on description:
where widget_desc like '%text%'

i also want to allow search on the exact widget_id if they know it:
where widget_desc like '%text%'
or widget_id = 98

or if they don't:
where widget_desc like '%text%'
or widget_id <> 0 -- or something like this


i can do some asp script logic to use one or the other, but is there an
alternate way in the sql to do this? i think a case statement might be
the right direction, but i'm not sure about that.

ben

Re: searched integer column

am 11.11.2004 16:14:56 von reb01501

ben h wrote:
> I have a basic page that returns a resultset of widgets (using an
> integer identity field amongst others) that i want to provide a better
> search for.
>
> currently i allow the user to seach on description:
> where widget_desc like '%text%'
>
> i also want to allow search on the exact widget_id if they know it:
> where widget_desc like '%text%'
> or widget_id = 98
>
> or if they don't:
> where widget_desc like '%text%'
> or widget_id <> 0 -- or something like this
>
>
> i can do some asp script logic to use one or the other, but is there
> an alternate way in the sql to do this? i think a case statement
> might be the right direction, but i'm not sure about that.
>
You should do one or the other. The resulting queries will be more
efficient. Avoid OR comparisons if at all possible.

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"