Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using Boolean logic in a SQL statement WHERE statement

Posted on 2013-01-12
3
Medium Priority
?
393 Views
Last Modified: 2013-01-17
I need to select records based on one criteria plus a 2nd variable criteria:

A and (B or C)

Currently my sql statement is:

sql2 = "SELECT COUNT(tblJournal.ChartID) AS CountEBSCO12NoContract " & _
"FROM tblJournal " & _
"WHERE tblJournal.FY12Vendor = 'EBSCO' AND tblJournal.FY12NatContract = 'No' OR " & _
      "tblJournal.FY12Vendor = 'EBSCO' AND tblJournal.FY12NatContact IS NULL "

Set obj2 = Server.CreateObject("ADODB.Recordset")
obj2.Open sql2, objConn


The error generated is:
     Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
     [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
0
Comment
Question by:Malloy1446
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 38771069
I don't use access anymore and only sql server.  But I think you need to use isnull(tblJournal.FY12NatContact )

WHERE tblJournal.FY12Vendor = 'EBSCO' AND tblJournal.FY12NatContract = 'No' OR " & _
      "tblJournal.FY12Vendor = 'EBSCO' AND isNull(tblJournal.FY12NatContact  )
0
 

Accepted Solution

by:
Malloy1446 earned 0 total points
ID: 38771074
FIgured it out.  Need to have the OR on the 2nd line of the WHERE statement.

THanks.
0
 

Author Closing Comment

by:Malloy1446
ID: 38786400
I was deleting my question because I found the solution myself. At the same time someone was providing a possible solution.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question