Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with my WHERE statement 1

Status
Not open for further replies.

mrdod

Technical User
Jun 12, 2006
103
US
I am attempting to pull in information from our Lotus Notes database into Excel and have been successful. Now I'm trying to pull in only the data based on certain criteria. In my code below I need to have the Entity = "AMK" I need to have the Line_Reject = "1" and the CQARNumber needs to have the year 2007 or 2006 or 2005 in it. I'm sure it's an easy solution for the experts but I don't do a whole lot of these type Queries.

Here's the code
strSQL = strSQL & " WHERE (C.Entity='AMK' AND C.LineReject='1'"
strSQL = strSQL & " AND C.CQARNumber LIKE '2007%'"
strSQL = strSQL & " OR C.CQARNumber LIKE '2006%'"
strSQL = strSQL & " OR C.CQARNumber LIKE '2005%')"

Any help would be Awesome!!! Thanks.
 
Perhaps this ?
strSQL = strSQL & " WHERE C.Entity='AMK' AND C.LineReject='1'"
strSQL = strSQL & " AND (C.CQARNumber LIKE '%2007%'"
strSQL = strSQL & " OR C.CQARNumber LIKE '%2006%'"
strSQL = strSQL & " OR C.CQARNumber LIKE '%2005%')"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hey PHV sorry I wasn't clear but my problem I'm getting is the values for LineReject are 1,2,3 and I only want it = "1" only. Thanks for pointing out the spacing isssue though. Thanks for your help.
 
I mainly pointed a parenthesis issue ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top