|
Posted by Erland Sommarskog on 03/02/06 10:14
Crumb (rowan.ian@gmail.com) writes:
> Many Thanks for the reply, I am one step nearer as this now runs
> without errors:)
>
> What I am trying to do is as follows:
>
> I have a table that contains all the phone calls in and out, (Called
> and Destination numbers). I am trying to create a asp page that will
> search the db for a telephone number (MMColParam) in either called or
> destinaition fields but only between two dates (MMColParam1 and 2)
>
> The information you gave me helped me return a result but it returns
> all calls and not just the ones between the dates specified.
Yes, I made a remark on this flaw, but I could not be sure what you wanted.
AND binds harder than OR, so you must use parentheses:
WHERE (OriginationNumber Like @MMColParam or
DestinationNumber Like @MMColParam) and
StartTime Between @MMColParam2 AND @MMColParam3
Else you get all rows with a matching Originationumber, no matter
the start time.
Think of OR as + and AND as *.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
[Back to original message]
|