Results 1 to 7 of 7

Thread: Using LIKE operator in multiple condition

  1. #1
    Junior Member
    Join Date
    Oct 2007
    Answers
    12

    Using LIKE operator in multiple condition

    If we have multiple conditions to check, can we use like operator?
    eg where empid like ('123%') or like ('23%')?


  2. #2
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: Using LIKE operator in multiple condition

    The LIKE operator is used in character string comparisons with
    pattern matching.

    If empid is defined as varchar Then
    select * from emp where empid like '123%'
    retrieve records of emp where empid starts with 123
    select * from emp where empid like '23%'
    retrieve records of emp where empid starts with 23


  3. #3

    Re: Using LIKE operator in multiple condition

    Like operator is used to retrieve records starting with the alphabet or numeric specified as the condition. For example,

    Select * from emp where emp_name like 'Joh%'

    This statement will retrieve the records where the employee name starts with "Joh"


  4. #4
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: Using LIKE operator in multiple condition

    LIKE operator is used for pattern matching you can combine multiple statments for different conditions using logical operators.


  5. #5
    Junior Member
    Join Date
    Nov 2006
    Answers
    1

    Re: Using LIKE operator in multiple condition

    u can combine like operator in multiple condition

    for eg. where (name like 'abc%' or name like 'pqr%');


  6. #6
    Junior Member
    Join Date
    May 2012
    Answers
    1

    Re: Using LIKE operator in multiple condition

    I have a table like employee containing name column.

    In name it contains:- SMITH,MARTIN,MILLER,ADAMS etc.

    I want a result from name whose first character is 'M', Second character can be any, But third character should not be 'R'.

    select name from employee where name like 'M_[^R]%' is fetching 0 results.

    Please suggest a query for oracle server.


  7. #7
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: Using LIKE operator in multiple condition

    You need to use REGEXP_LIKE for the purpose.


  8.  Sponsored Ads
    Ad


     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact