Re: escaped underscore

Gonzalo "D?az" <[email protected]> Thu, 14 Sep 2006 10:10:56 -0700 (PDT)
Newsgroups gmane.comp.db.mckoi
Message-ID <[email protected]>
Thanks, that solved my problem.

   Gonzalo

--- Stefaan A Eeckels <[email protected]> wrote:

> On Wed, 13 Sep 2006 18:33:51 -0700 (PDT)
> Gonzalo "Díaz" <[email protected]> wrote:
> 
> > Does Mckoi understand escaped underscores in a
> LIKE
> > statement? For example, 
> > 
> >   SELECT * FROM EMAILS_TABLE WHERE EMAIL LIKE
> '%\_%'
> > 
> >   ... so that it returns all email addresses
> > containing underscores.
> 
> It does certainly support the escaped underscore, I
> tried it just now
> with exactly the syntax you're giving above.
> 
> > I tried the backslash but it doesn't seem to work.
> I
> > also tried a varied number of backslashes (2, 4,
> etc),
> > to allow for Java backslash escaping, regular
> > expressions, etc., to no avail.
> 
> Aha - you're trying to do this using ODBC and Java.
>  
> > If true, is there a workaround? I can use prepared
> > statements, but still need to write the right SQL.
> 
> Here's what works, I tried it just now:
> 
> String query = "SELECT * FROM EMAILS_TABLE WHERE
> EMAIL LIKE '%\\_%'";
> 
> Here's the code I tried (setup stuff omitted):
> 
>  String query =  "select name from users where name
> like '%\\_%'";
>  System.out.println(query);
> 
>  try {
>      Statement stmt = edb.createStatement();
>      ResultSet rs = stmt.executeQuery(query);
>      while (rs.next()) {
>          System.out.println("Name: " +
> rs.getString(1));
>      }
>      rs.close();
>      stmt.close();
>  } catch (Exception e) {
>      System.out.println(e.getMessage());
>  }
> 
> It correctly retieves the users with an underscore
> in their name from
> my test McKoi database.
> 
> Take care,
> 
> -- 
> Stefaan
> -- 
> As complexity rises, precise statements lose
> meaning,
> and meaningful statements lose precision. -- Lotfi
> Zadeh 
> 
> 
>
---------------------------------------------------------------
> Mckoi SQL Database mailing list 
> http://www.mckoi.com/database/
> To unsubscribe, send a message to
> [email protected]
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


---------------------------------------------------------------
Mckoi SQL Database mailing list  http://www.mckoi.com/database/
To unsubscribe, send a message to [email protected]