Home » SQL & PL/SQL » SQL & PL/SQL » Querying the underscore
Querying the underscore [message #1462] Thu, 02 May 2002 15:37 Go to next message
Roland
Messages: 24
Registered: March 2002
Junior Member
My problem is this:
I'm trying to query user logins containing the underscore like e.g. 'ROLAND_BENDER' - all I could find out so far is that the '_' has to be escaped to avoid treating it as a command but no matter what I'm trying, it doesn't do it right. (the escape character for my database is the backslash):
select count(*) from rb.employee r where r.login like '%_%';

Result:

COUNT(*)
---------
0

Who knows what I'm missing?

Thanks much!
Roland
Re: Querying the underscore [message #1466 is a reply to message #1462] Thu, 02 May 2002 21:25 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
select count(*) from rb.employee where login like '%_%' escape '';


or

select count(*) from rb.employee where instr(login, '_') > 0;
Re: Querying the underscore [message #1469 is a reply to message #1462] Fri, 03 May 2002 05:25 Go to previous message
Roland
Messages: 24
Registered: March 2002
Junior Member
That was exactly what I needed - thanks so much!
I mistakenly thought that the escape character was predefined in the database...

Again: THANKS!
Roland
Previous Topic: Inserting rows into table
Next Topic: Trigger Mutation Problem
Goto Forum:
  


Current Time: Fri Apr 26 03:21:24 CDT 2024