Search code examples
oracle-databasesql-like

select with like return results with ( character


I'm running plsql developer on oracle 11g.

My select with like return results with ( character although I didn't requested

 SELECT  * FROM TableA a where a.cofiguration like '%a_mobile_sw';

it return also records with configuration with values a_mobile_sw and also a_mobile(sw

How it return record with '(' character inside although not requested?


Solution

  • If you're searching for the underscore character, you need to escape it, like so:

    SELECT *
    FROM   TableA a
    where  a.cofiguration like '%a\_mobile\_sw' escape '\';
    

    With the like comparison, % is a multiple character wild-card, and _ is a single character wild-card, which is why you were seeing odd results. By escaping the underscore, you tell Oracle to treat it as an underscore rather than a wild-card.