Home » SQL & PL/SQL » SQL & PL/SQL » _ in SQL Queries
_ in SQL Queries [message #10603] Tue, 03 February 2004 02:44 Go to next message
Sebastian S
Messages: 4
Registered: February 2004
Junior Member
I am having a problem when using the "_" character in a SQL statement.

My query goes like this:

SELECT * FROM PRINCIPALS WHERE NAME LIKE '_'

and all i get are the rows where the lenght of name is equal to 1 character!!! Further testing has proved that every "_" is taken like the "?" in DOS dir command, it replaces one character.

If i wanted to search for a valid name which actually uses the underscore at the beginning of its name, how would i do it then?

Thanks!
Re: _ in SQL Queries [message #10604 is a reply to message #10603] Tue, 03 February 2004 03:08 Go to previous messageGo to next message
Padders
Messages: 79
Registered: January 2004
Member
Check the syntax of LIKE in the documentation. You can optionally specify an escape character (using the ESCAPE keyword) which indicates that the following character should not be treated as a meta-character, so for example for names beginning with '_' you could do...
WHERE name LIKE '/_%' ESCAPE '/';
Re: Thanks! [message #10605 is a reply to message #10604] Tue, 03 February 2004 03:13 Go to previous message
Sebastian S
Messages: 4
Registered: February 2004
Junior Member
It worked ok!!! Thanks for answering so fast!!!! Good luck, man!

Sebastian
Previous Topic: Select count (distinct) - A Query
Next Topic: Need to know the name of Data dict. through which we can find out the value in a column
Goto Forum:
  


Current Time: Fri Apr 26 16:19:56 CDT 2024