Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2002
    Posts
    3

    Unanswered: Using Like or Wildcard

    I am searching against a sql database and I want to return all active courses and all courses whose field code begins with a 10. This is the table (LEDef) & some of the info that is in the field.

    LEDef_Cd
    DB356
    40ILTC0007
    HW442
    51NWAC000020
    10-CSSR-2013
    10-FESW-0002

    I want to return only the "10-" stuff. Here is part of the code I'm using in 2 of my files. I've tried everything but nothing seems to work:

    r.open "SELECT LEDef_PK FROM LEDef WHERE LEDef_ActiveInd = 1 AND LEDef_Cd LIKE '10-%'"

    r.Open "SELECT LEDef_Cd, LEDef_Name, LEDef_Desc, LEDef_ActiveInd, FROM LEDef WHERE LEDef_ActiveInd = 1 and LEDef_Cd LIKE '10-%'"and LEDef_PK = " & Request.QueryString("id"),

  2. #2
    Join Date
    Aug 2002
    Location
    Prague
    Posts
    77

    Re: Using Like or Wildcard

    have you tried enclosing - charactrer in brackets? e.g. LIKE '10[-]%'

  3. #3
    Join Date
    May 2003
    Posts
    26
    A question regarding exactly what you are looking for, because what you described in your question seems different than whats in your query.

    [i]I want to return all active courses and all courses whose field code begins with a 10
    This is saying the record must have LEDef_ActiveInd = 1 or LEDef_Cd LIKE '10-%', either one of these will satisfy the conditions for your result set.

    What you have coded says a record must have both LEDef_ActiveInd = 1 and LEDef_Cd LIKE '10-%' to be included. Having one or the other is not enough.

    If you want either condition to be enough try

    SELECT LEDef_PK FROM LEDef WHERE LEDef_ActiveInd = 1 OR LEDef_Cd LIKE '10-%'

Posting Permissions

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