_ in SQL Queries [message #10603] |
Tue, 03 February 2004 02:44 |
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 |
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 '/';
|
|
|
|