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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LIKE is driving me nuts 1

Status
Not open for further replies.

Gatorajc

MIS
Mar 1, 2002
423
US
Can someone please tell my why the below code is not working the way it should. The LIKE part of it does not work at all like it should. If I put ralph it returns something even if there is nothing in it even close even if I leave the keyword blank it returns something. It does not return errors of any kind.

sqlString1 = "Select *"

sqlString1 = sqlString1 & " From help A INNER JOIN type B ON A.type = B.RecNum"

if Len(list) > 0 then
sqlString1 = sqlString1 & " Where Type = '"& issues(0)&"'"

for i = 1 to ubound(issues)
sqlString1 = sqlString1 & " or"
sqlString1 = sqlString1 & " Type = '"& issues(i)&"'"
next

end if

if Len(keyword) > 0 then

sqlString1 = sqlString1 & " or"
sqlString1 = sqlString1 & " Issue LIKE '%" & keyword & "%'"

end if

sqlString1 = sqlString1 & " Group By Type, ASAP"
sqlString1 = sqlString1 & " Order By Type, ASAP Desc" AJ
I would lose my head if it wasn't attached. [roll1]
 
Like is not the problem, it is rather that you use or. I.e. your query looks like

select * from help A INNER JOIN type B ON A.type = B.RecNum
where type = 'this' or type = 'that' or issue like '%ralph%'

when finished.

Shouldn't that rather be

select * from help A INNER JOIN type B ON A.type = B.RecNum
where (type = 'this' or type = 'that')
and issue like '%ralph%'
 
That was it. Thanks you look at something to long it starts looking right but now I see it AJ
I would lose my head if it wasn't attached. [roll1]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top