using "like" in sql statements

Results 1 to 5 of 5

Thread: using "like" in sql statements

  1. #1
    Ben Roy Guest

    Default using "like" in sql statements

    Ok I know I have dealt with this once a long time ago but for the life of me I can&#039t figure out where it was to look it up. I need to build a statement like this:<BR><BR>sql = "SELECT FirstName FROM tblNames WHERE FirstName Like &#039*tim*&#039"<BR> sql, cnn, 1, 1<BR><BR>The problem is when I do this it returns no records. This is via ODBC to an access db. If I take the EXACT same statement and paste it into a qry in access it works fine. What gives?

  2. #2
    fl1rt Guest

    Default RE: using

    Have you tried replacing the "*" with a "%" ????

  3. #3
    Join Date
    Dec 1969

    Default RE: using

    Have you looked into casing??? I think that Access will perform the query case insensative.<BR><BR>sql = "SELECT FirstName FROM tblNames WHERE UCase(FirstName)Like &#039*TIM*&#039"<BR><BR><BR>HTH<BR><BR>Jerry<BR><B R><BR>

  4. #4
    Ben Roy Guest

    Default Woohoo!

    On the nose! As soon as I read it I remembered that&#039s what is was (that&#039s always the way it goes). Anyway, thanks.

  5. #5
    fl1rt Guest

    Default RE: Woohoo!

    I remember woohoo-ing just the same way when someone told me about the %like% syntax 9 months ago. very nice<BR><BR>I&#039m only too glad to pass that knowledge on for someone that at least tried to get some code working!<BR>- rather than ask for someone to write it all for them ;)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts