Menu

LIKE operator brackets not working.

Help
2015-11-23
2015-12-05
  • David Naegle

    David Naegle - 2015-11-23

    I am writing an Access database update program in Java using UCANACCESS 3.0.2. I can access the .mdb file and read and build tables, but I am having a problem with LIKE operators.
    I cannot use [0-9] in a LIKE statement. In the example shown, I am trying to select part numbers from a table named TEST. In this example I can use percent or asterisk or hash and get the same result of 4 lines selected from the table, since there are four lines in the table that match the text and end with a numeral.

    selTable = "SELECT part_number FROM TEST "+
        "WHERE (TEST.part_number LIKE '10-59-8000%')";
    rs = s.executeQuery(selTable);
    

    When I try to change the query to use brackets to select a group of acceptable characters.

    selTable = "SELECT part_number FROM TEST "+
        "WHERE (TEST.part_number LIKE '10-59-8000[0-9]')";
    rs = s.executeQuery(selTable);
    

    This selects zero lines.
    The features list for UCANACCESS says it handles brackets for defining character intervals.
    Sure I can work around this with the hash character, but what if I need a different set of characters, like [A-F]?
    Also, I know MSAccess and UCANACCESS are not the same, but just for completeness I tested and the brackets do work in queries inside MSAccess.
    Thanks for any suggestions!

     
  • Marco Amadei

    Marco Amadei - 2015-11-24

    [A-F],[!A-F] should work. If [0-9] doesn't, it's a bug. No time to confirm in this very moment, but if so, I'll fix it next week and release the bug fix with the 3.0.3.

     
  • Marco Amadei

    Marco Amadei - 2015-12-05

    Fixed in svn trunk(digit intervals allowed).

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.