Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2009
    Posts
    25

    Unanswered: Using like in sql to compare 2 columns

    I am trying a sql like below:
    <code>
    SELECT F.*
    FROM table1 D,
    table2 C,
    table3 E,
    table4 F
    WHERE C.TYPE = D.TYPE
    AND C.SUB_TYPE = D.SUB_TYPE
    AND C.ID = 5316
    AND C.TYPE like E.DESCRIPTION%
    </code>
    I basically want to code the last line so that if C.TYPE = 'Customer' and E.DECRIPTION is 'Customer Service Center' it gets picked up by the last line of the sql

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    It would be easier if you posted test case, but - from what I understood - it should be vice versa (with a slight modification):
    Code:
    SQL> select * from table2;
    
    TYPE
    ------------------------------
    Customer
    Something else
    
    SQL> select * from table3;
    
    DESCRIPTION
    ------------------------------
    Customer service center
    service center
    
    SQL> select c.type, e.description
      2  from table2 c, table3 e
      3  where e.description like c.type || '%';
    
    TYPE                           DESCRIPTION
    ------------------------------ ------------------------------
    Customer                       Customer service center
    
    SQL>

  3. #3
    Join Date
    Feb 2009
    Posts
    25
    Ok that was straightforward, thanks a lot for the prompt reply!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •