Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using like and the "_" 2

Status
Not open for further replies.

jetec

Technical User
May 2, 2006
17
US
SQL> SELECT TNAME FROM TAB WHERE TNAME LIKE 'TEST_%';

TNAME
------------------------------
TEST2
TESTA
TESTB
TESTING123
TESTINGA
TESTJE
TEST_12_JE
TEST_13_JE
TEST_PROCESSES
TEST_TAB

This is pulling all of these..i only want it to pull the following:

TEST_12_JE
TEST_13_JE
TEST_PROCESSES
TEST_TAB

Any ideas?
 
jetec,

Code:
SELECT tname
  FROM tab
 WHERE SUBSTR(tname,1,5) = 'TEST_';

ought to do what you want.

Regards

Tharg

Grinding away at things Oracular
 
Jetec,

You can produce the results that you want by using (and declaring) an excape character of your choosing. In the example, below, I have used the octothorpe ("#", aka "pound-sign") character to satisfy your need (using your original data):
Code:
select * from tab where tname like 'TEST#_%' escape '#';

TNAME
--------------
TEST_12_JE
TEST_13_JE
TEST_PROCESSES
TEST_TAB
Let us know your thoughts.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I can provide you with low-cost, remote Database Administration services: see our website and contact me via www.dasages.com]
 
Mufasa said:
...excape character...
I can be such a loser sometimes...Thank you, Jetec, for the Purple Star, but that type of inexcusable typographical/grammatical mistake means I don't deserver the reward.[blush][banghead]

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I can provide you with low-cost, remote Database Administration services: see our website and contact me via www.dasages.com]
 
[banghead][banghead][banghead][banghead][banghead]

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I can provide you with low-cost, remote Database Administration services: see our website and contact me via www.dasages.com]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top