Pssst...you missed a )
<smirk>
"SELECT * FROM Referrals " _
& " WHERE (" _
& "(Referrals.CustomerID=1)" _
& " AND (Referral.Product='Checking')" _
& " AND (Referrals.TellerID IN ('T66','T54','T22'))" _
& ")"
And, OF COURSE, I'm only razzing you on it cos' to think that *I* figured
out the missing ) is a miracle! This was truly an exercise in
Quote-metrics<g> seeing that I had to assemble the above string from 3
separate code loops. I need a beer! ;-)
Dian ~
-----Original Message-----
From: Dian D. Chapman [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 09, 2004 11:16 PM
To: [EMAIL PROTECTED]
Subject: RE: [ASP] Help with a weird query?
Very cool, Shawn! Thanks so much!
Yeah, I tried the parens earlier and that DID fix the problem with the data
mistake. As you can probably guess...whichever ended up to be the first ID
after the AND to start the ID...would be considered as an AND so I was
getting all the 444 listings no matter what customer it was for. So that was
bad...well, except for Teller 444 who would have been getting credit for
every sale!<g>
Once I added the parens around the IDs, that segmented it off and it worked
great.
But thanks so much for the IN...I didn't know about that. Speaking of
which...any recommendations on a good reference book for all this crap? I
know a lot of it is just learned through time/experience. But I have a dozen
SQL books and, although I haven't read through all of them, I do use many as
references and none have all this stuff listed so I'd at least know my
choices.
Really appreciate the info...I'll go rework that code.
Dian D. Chapman, Technical Consultant
Microsoft MVP, Certified MOS Expert
Editor/TechTrax Ezine
Free Tutorials: http://www.mousetrax.com/techtrax
Free Word eBook: www.mousetrax.com/books.html
Optimize your business docs: www.mousetrax.com/consulting
Learn VBA the easy way: www.mousetrax.com/techcourses.html
-----Original Message-----
From: Shawn K. Hall [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 09, 2004 9:48 PM
To: [EMAIL PROTECTED]
Subject: RE: [ASP] Help with a weird query?
Hi Dian,
> Thanks...I did get it working. What I do is toss all selected IDs
out into
> an array from the list box after the user clicks OK. Then I build
the SQL
> statement from the array that slips the IDs into a continual
string of OR
> statements.
Yuck. Use IN:
"SELECT * FROM Referrals WHERE Referrals.CustomerID=1 " _
& "AND Referral.Product='Checking '" _
& "AND Referrals.TellerID IN ('T66','T54','T22')"
This way you don't have to do any fancy OR'ing of your input. You
should, however, segregate your parameters so each one is explicitly
parsed:
"SELECT * FROM Referrals " _
& " WHERE (" _
& "(Referrals.CustomerID=1)" _
& " AND (Referral.Product='Checking')" _
& " AND (Referrals.TellerID IN ('T66','T54','T22')" _
& ")"
I broke it into several lines so you could see the para coupling.
Regards,
Shawn K. Hall
http://ReliableAnswers.com/
'// ========================================================
Love truth, and pardon error.
-- Voltaire
---------------------------------------------------------------------
Home : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
Post : [EMAIL PROTECTED]
Subscribe : [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
---------------------------------------------------------------------
Yahoo! Groups Links
--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.289 / Virus Database: 265.4.8 - Release Date: 12/8/2004
--
This email scanned and certified clean by AVG!
Checked by AVG Anti-Virus.
Version: 7.0.289 / Virus Database: 265.4.8 - Release Date: 12/8/2004
---------------------------------------------------------------------
Home : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
Post : [EMAIL PROTECTED]
Subscribe : [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
---------------------------------------------------------------------
Yahoo! Groups Links
--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.289 / Virus Database: 265.4.8 - Release Date: 12/8/2004
--
This email scanned and certified clean by AVG!
Checked by AVG Anti-Virus.
Version: 7.0.289 / Virus Database: 265.4.8 - Release Date: 12/8/2004
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/17folB/TM
--------------------------------------------------------------------~->
---------------------------------------------------------------------
Home : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
Post : [EMAIL PROTECTED]
Subscribe : [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
---------------------------------------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/active-server-pages/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/