Results 1 to 5 of 5

Thread: Why can't I use the "LIKE" query?

  1. #1

    Thread Starter
    Addicted Member bulletrick's Avatar
    Join Date
    Jul 2005
    Location
    Philippines
    Posts
    248

    Question Why can't I use the "LIKE" query?

    I am using a VB6 Enterprise Edition, and I am accesing an MS Access database using MS Jet 4.0...

    How can I use the LIKE query? If I can't, how can I search a database for a substring instead of the whole data in the record?

  2. #2
    Fanatic Member kaffenils's Avatar
    Join Date
    Apr 2004
    Location
    Norway
    Posts
    946

    Re: Why can't I use the "LIKE" query?

    Quote Originally Posted by bulletrick
    I am using a VB6 Enterprise Edition, and I am accesing an MS Access database using MS Jet 4.0...

    How can I use the LIKE query? If I can't, how can I search a database for a substring instead of the whole data in the record?
    LIKE is used instead of = in the WHERE clause and use it with wildcards. The most common wildcards are * and ?.

    Examples:
    Code:
    select * from MyTable where MyColumn like 'bulletrick*'
    This query returns all rows where MyColumn begins with bulletrick.
    Code:
    select * from MyTable where MyColumn like '*bulletrick'
    This query returns all rows where MyColumn end with bulletrick.
    Code:
    select * from MyTable where MyColumn like '*bulletrick*'
    This query returns all rows where MyColumn contains bulletrick somewhere in the string.

  3. #3

    Thread Starter
    Addicted Member bulletrick's Avatar
    Join Date
    Jul 2005
    Location
    Philippines
    Posts
    248

    Re: Why can't I use the "LIKE" query?

    Quote Originally Posted by kaffenils
    LIKE is used instead of = in the WHERE clause and use it with wildcards. The most common wildcards are * and ?.

    Examples:
    Code:
    select * from MyTable where MyColumn like 'bulletrick*'
    This query returns all rows where MyColumn begins with bulletrick.
    Code:
    select * from MyTable where MyColumn like '*bulletrick'
    This query returns all rows where MyColumn end with bulletrick.
    Code:
    select * from MyTable where MyColumn like '*bulletrick*'
    This query returns all rows where MyColumn contains bulletrick somewhere in the string.
    Yep, I am using those statements but my program still produces errors.

  4. #4
    Fanatic Member kaffenils's Avatar
    Join Date
    Apr 2004
    Location
    Norway
    Posts
    946

    Re: Why can't I use the "LIKE" query?

    Can you post the error message and query.

  5. #5
    Hyperactive Member
    Join Date
    May 2005
    Posts
    324

    Re: Why can't I use the "LIKE" query?

    You are using single not double quotes are you (as in the examples given).

Posting Permissions

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



Click Here to Expand Forum to Full Width