Not like operator not working while matching text from two tables

Hello  Everyone,
I want to find the Id from table child where the column name  is not matching with at least first term of column name from parent table.
I am not getting proper output. can anyone help me.
Output should be :-->ID 6 & 7
with child as
(select 1 id, 'Genentech'  as name from dual union all
select 2 id, 'Altana Pharma AG'  as name from dual union all
select 3 id, 'Yamanouchi'  as name from dual union all
select 4 id, 'Sigma-Tau'  as name from dual union all
select 5 id, 'Schering-Plough'  as name  from dual union all
select 6 id, 'Pharma AG'  as name from dual union all
select 7 id, 'Pfizer'  as name  from dual
), parent as
(select 1 id, 'Genentech number'  as names from dual union all
select 2 id, 'Altana Pharma AG'  as names from dual union all
select 3 id, 'AG site/Yamanouchi'  as names from dual union all
select 4 id, 'sigMa Tau'  as names from dual union all
select 5 id, 'Schering-Plough'  as names  from dual union all
select 6 id, 'AG'  as names from dual union all
select 7 id, 'Inc'  as names  from dual
select *
from child a, parent bc
where a.id=bc.id
and upper(a.name) not like (bc.names)

One way:
WITH child AS
        (SELECT 1 id, 'Genentech' AS name FROM DUAL
         UNION ALL
         SELECT 2 id, 'Altana Pharma AG' AS name FROM DUAL
         UNION ALL
         SELECT 3 id, 'Yamanouchi' AS name FROM DUAL
         UNION ALL
         SELECT 4 id, 'Sigma-Tau' AS name FROM DUAL
         UNION ALL
         SELECT 5 id, 'Schering-Plough' AS name FROM DUAL
         UNION ALL
         SELECT 6 id, 'Pharma AG' AS name FROM DUAL
         UNION ALL
         SELECT 7 id, 'Pfizer' AS name FROM DUAL),
     parent AS
        (SELECT 1 id, 'Genentech number' AS names FROM DUAL
         UNION ALL
         SELECT 2 id, 'Altana Pharma AG' AS names FROM DUAL
         UNION ALL
         SELECT 3 id, 'AG site/Yamanouchi' AS names FROM DUAL
         UNION ALL
         SELECT 4 id, 'sigMa Tau' AS names FROM DUAL
         UNION ALL
         SELECT 5 id, 'Schering-Plough' AS names FROM DUAL
         UNION ALL
         SELECT 6 id, 'AG' AS names FROM DUAL
         UNION ALL
         SELECT 7 id, 'Inc' AS names FROM DUAL)
SELECT *
  FROM child a, parent bc
WHERE a.id = bc.id
       AND UPPER (REGEXP_REPLACE (a.name, '[^[:alnum:]]')) NOT LIKE
              '%' || UPPER (REGEXP_REPLACE (bc.names, '[^[:alnum:]]')) || '%';
Regexp_replace can be avoided and replaced by translate there if you know for sure what characters you are expecting.
ID NAME ID_1 NAMES
1 Genentech 1 Genentech number
3 Yamanouchi 3 AG site/Yamanouchi
7 Pfizer 7 Inc
Cheers,
Manik.

Similar Messages

  • How do I extract matching records from two tables?

    I'm trying to extract client records from our client database to put together a very targeted email campaign. As an example, the result I want is a list of names and email addresses of those clients who have a record in our system, have not had a visit in our clinic in the last year, and live within 200 miles of our clinic. I can capture the first two criteria in one extract, and the second in another. I can then import those as tab delimited data into Numbers. What I then need to do is create a third table that represents ONLY those records that exist in both tables.
    Can someone tell me if this is possible and if so, how to do it?
    I'd be very appreciative of any help, thank you.

    conejo61 wrote:
    I can then import those as tab delimited data into Numbers. What I then need to do is create a third table that represents ONLY those records that exist in both tables.
    You can create a column that generates a serial marker on the table from which you want to transfer the data, making all the names that also appear on the other table. Not that the formula will mark only exact matches.
    Here's a short example:
    Table 1 on the left, is one of the two tables imported from the tab delimited data files. It has other data, but only the names in column A are used to identify records appearing on both tables.
    Table 2 on the right, contains the names and other data (represented by the email addresses in column B), to be transferred to the third table.
    Column C of this table contains the formula that counts off the rows containing names appearing on both tables. The version below is in C2, and is filled down to the end of the column.
    =IF(COUNTIF(Table 1 :: $B,A2)>0,MAX($C$1:C1)+1,"")
    Note that jane Doe is not counted (or transferred) as her name is recorded differently on the two tables.
    Table 3 is the results table. It contains one formula for each column to be transferred from Table 2 to Table 3.
    A2:   =IF((ROW()-1>MAX(Table 2 :: $C)),"",LOOKUP(ROW()-1,Table 2 :: $C,Table 2 :: $A))
    B2:   =IF((ROW()-1>MAX(Table 2 :: $C)),"",LOOKUP(ROW()-1,Table 2 :: $C,Table 2 :: $B))
    Regards,
    Barry
    EDIT: I was working in Numbers '09 when developing this, and got the following warning when I saved a copy as an iWork '08 document:
    Referencing row or column ranges that include header or footer cells isn't supported. The formula references were updated to exclude header and footer cells.
    The formulas in Table 2::C2 references C1. You may have to ensure that Table 2 does not include a header row.
    B.
    EDIT2: A check on the file in Numbers '08 showed no apparent change to the formula, and editing Jane Doe's name on table 1 resulted in her name being added to Table 3.
    Message was edited by: Barry

  • Find matching records from two tables, useing three key fields, then replace two fields in table1 from table2

    I have two tables - table1 and table2 - that have the exact same schema. There are three fields that can be used to compare the data of the two tables, field1, field2, and field3. When there are matching rows in the two tables (table1.field1/2/3 = table2.field1/2/3)
    I want to replace table1.field4 with table2.field4 and replace table1.field5 with table2.field5.
    I have worked with the query but have come up with goobly goop. I would appreciate any help. Thanks.

    If your field1, field2, and field3 combinations in these tables are unique, you
    can do a join on them.
    Select t1.field4, t2.field4 , t1.field5, t2.field5
    from table1 t1 inner join table2 t2 on t1.field1 =t2.field1 and t1.field2=t2.field2 AND t1.field3=t2.field3
    --You can update your table1 with following code:
    Merge table1 t1
    using table2 t2 on
    on t1.field1 =t2.field1 and t1.field2=t2.field2 AND t3.field3=t2.field3
    When matched then
    Update Set
    t1.field4= t2.field4
    ,t1.field5 = t2.field5 ;

  • Matching records from two tables even when the ID of a person is null.

    I have a MySQL named Natural Systems which is a magazine account that it member's will both sell handmade items wherein the proceeds will go into the Natural Systems account and each member also give a weekly donation. All of the proceeds will help toward the printing of the subsequent volumes. both of the selling of handmade items and the weekly dues  happens during the same week or the same magazine volume number. I am trying to write a query that will pull both of the sales as well as the weekly dues payments weather they have paid or not.
    SELECT foiid, trim(concat(name.fname,' ',name.lname)) AS no_ns, nspayamt, DATE_FORMAT(nspaydate, '%m/%d/%Y') FROM name LEFT JOIN nspay ON nspayfoiid = foiid and volume  = '27' WHERE nspayfoiid is null AND  type = 'Registered' AND city = 'richmond' AND status = 'a' group by foiid ORDER BY no_ns
    This code will bring up the following names of those who did not pay weekly dues during volume 2:
    Christopher Gabb
    Michael banks
    Timothy Hardin
    However there is another table I wish to call the same Individuals who sold magazine during the same week of volume 27
    SELECT trim(CONCAT(name.fname,' ',name.lname))AS Sold,
    round(sum(fcnsales.salesamt)) as TOTAL_Mags_SOLD FROM name, fcnsales WHERE fcnsales.salesfoiid = name.foiid
    AND fcnsales.salesvolume '27'  GROUP BY name.foiid ORDER BY TOTAL_mags_SOLD desc;
    This above code produces the following results:
    Sold                             TOTAL_Mags_SOLD  
    Christopher Gabb        50
    Michael banks             36       
    Timothy Hardin           12
    I would like to combine the two queries to produce the following
    Sold                             TOTAL_Mags_SOLD   nspayamt
    Christopher Gabb          50                                none    
    Michael banks               36                                none
    Timothy Hardin            12                               none
    can anyone give me a direction to go to?

    If your field1, field2, and field3 combinations in these tables are unique, you
    can do a join on them.
    Select t1.field4, t2.field4 , t1.field5, t2.field5
    from table1 t1 inner join table2 t2 on t1.field1 =t2.field1 and t1.field2=t2.field2 AND t1.field3=t2.field3
    --You can update your table1 with following code:
    Merge table1 t1
    using table2 t2 on
    on t1.field1 =t2.field1 and t1.field2=t2.field2 AND t3.field3=t2.field3
    When matched then
    Update Set
    t1.field4= t2.field4
    ,t1.field5 = t2.field5 ;

  • "HAVING NOT LIKE" isn't working

    When I wanted to sum the value of all inputted device data except one type I had to put this...
    SELECT AttributeName, DateAdd(minute,-5,System.TimeStamp) as WinStartTime, system.TimeStamp as WinEndTime, DeviceId, Avg(Value) as Value, Count(*) as EventCount
    FROM input
    GROUP BY TumblingWindow(minute, 5), DeviceId, AttributeName
    Having 'OK' = CASE
         WHEN  AttributeName LIKE '%/pir/%' THEN 'PIR'
         ELSE 'OK'
    END
     ...instead of simply saying...
    SELECT AttributeName, DateAdd(minute,-5,System.TimeStamp) as WinStartTime, system.TimeStamp as WinEndTime, DeviceId, Avg(Value) as Value, Count(*) as EventCount
    FROM input
    GROUP BY TumblingWindow(minute, 5), DeviceId, AttributeName
    Having  AttributeName NOT LIKE '%/pir/%'
    It accepted the "NOT LIKE" version, but didn't produce any output.
    Does anyone understand why NOT LIKE doesn't work in this scenario?
    Thanks in advance,
    Peter
    #PEJL
    Got any nice code? If you invest time in coding an elegant, novel or impressive answer on MSDN forums, why not copy it over to
    TechNet Wiki, for future generations to benefit from! You'll never get archived again, and
    you could win weekly awards!
    Have you got what it takes o become this month's
    TechNet Technical Guru? Join a long list of well known community big hitters, show your knowledge and prowess in your favoured technologies!

    Hi Peter,
    Could you please try your scenario again? We deployed a service change recently which should support this scenario.
    We have a different issue where testing of queries in the browser (without starting a job) does not have this fix yet, that change should be rolled out as soon as it is ready.
    Zafar
    Zafar Abbas

  • I do not like how it works on my new iPad ios6.

    I do not like how it works on my new iPad ios6. How do I go back to 5.1.1?
    Help please.

    There are  parts of your recent post that I do not understand, you can try a few things though.
    press and hold the home and sleep/wake buttons until the apple logo appears on the screen, and then let go.
    settings/general/reset/reset all settings
    if the above do not solve your issue then a complet restore may be necessary.

  • I have a pioneer 50 inch plasma   I purchased new from the company back in 2005.   I tried to hook up an Apple Tv to the pioneer receiver that came with the TV.   I can not get it to work.   The receiver has two HDMI  inputs in the back.

    I have a pioneer 50 inch plasma + I purchased new from the company back in 2005.   I tried to hook up an Apple Tv to the pioneer receiver that came with the TV.   I can not get it to work.
    The receiver has two HDMI  inputs in the back.  However they say they are not for PC's.  Furthermore they must be set up by going to the home menu.    I tried everything, but I can not get the receiver to talk to the Apple TV. I even tried a connector that uses an HDMI to the Apple TV that has the other side of the cable as 5 RCA cables.  I could not get the receiver to see the Apple TV.   I have a newer TV in the house, it has no problem talking with the Apple TV.  But this older system seems to be handicapped in its ability to talk with the newer Apple TV system.
    My Email is [email protected] 
    Do you have any suggestions
    Thanks
    Bob

    I could not access the Apple TV on the television.   If I put the Apple TV directly into by TV, I have an external sound system (entertainment system), therefore I worry that I would by pass the audio.
    Thanks for taking your time to attempt to help!   Any more suggestions would be greatly appreciated.
    Bob

  • I would like to remove a short gray edge from two images. I need help in that I am not yet able to use PhotoShop. Could somebody kindly help me with this?

    I would like to remove a short gray edge from two images. I need help in that I am not yet able to use PhotoShop. Could somebody kindly help me with this?

    I doubt it Doc Maik, but I am certainly happy to learn The image is this one (and a similar one). They would be beautiful portraits if not for the "extra mouth". The grey edge that I would like to remove is the excess of (grey) mouth that is actually my horse's chin, but that in the pictures looks like a wider, looping mouth. Practically, looking at the picture, the "extra mouth" to the left. What I would love it to be able correct that to look like a normal mouth, which means that half of the protruding edge should be removed. I am not sure I was able to explain myself, but here is one of the two pictures. I thank you for you kindness in being available to advise me.

  • Selecting from two tables and confirming from them despites they not relate

    Please I need a query to select from two tables that are not related to each other.
    I also want to confirm data's as in verify wether what the user has entered is in accordance with what is in the tables
    Examples
    the first table is named "Card" and the second table is named "Student_Details"
    Card table contains a column named "Pin_Number".
    The Student_Details table contains fields such as Exam_Number, Name, Age, Sex.
    The user has to Enter the Pin_Number which has to be confirmed in the Card table and Exam_Number which has to be confirmed in the Student_Details table and verify that both data's are correct.
    Please I need the SQL and PL/SQL queries for this problem.
    Thanks

    Hi,
    I think you need two different queries
    You can write a procedure like:
    create or replace procedure p1 (p_pin_number number, p_exam_number)
    is
      r_card_row            card%rowtype;
      r_student_details     student_details%rowtype;
      cursor c1 is
      select *
        from card
       where pin_number = p_pin_number;
      cursor c2 is
      select *
        from student_details
       where exam_number = p_exam_number;
    begin
      open c1;
        loop
          fetch c1 into  r_card_row;
          exit when c1%notfound;
          ....  do whatever you want..... and the samething you can do with other cursor
        end loop;
      close c1;
    end p1;Hope this helps
    Ghulam

  • To find matching records across two tables

    Hi folks,
    I have a question regarding modifying the query. I am trying to compare the data between two tables, there are matching records in two tables, but are not in the same order.  How to modify the query so that it finds the matching record between  the two tables?
    Here is my code
      loop at itab_A.
          read table itab_B with key
                 employeenumber = itab_zmgr_training-empid binary search.
              if sy-subrc = 0.
    Any thoughts?
    Thanks,
    Sk
    Here I am getting the return value as '4'

    I have tried all that, but why is it that while reading a record from itab_B I see no record in the header line,
    Let me paste the entire code of what I am trying to achieve.
    data: itab_A like A occurs 0 with header line.
    data: itab_B like B occurs 0 with header line.
    some validation.....
    loop at itab_A.
    read table  itab_B with key  employee number = empid binary search.
      if sy-subrc =0.
    per form validation.
    else.
    perform validation.
    endif.
    endloop.
    My observation: while reading recrod from itab_B the header line is clear, no record is read here hence sy-subrc = 0.
    How can I correct this? Since it is not reading any record from itab_B no matching record is found.
    Any thoughts would be really helpful.
    Thanks,
    Santhosh.

  • Error while selecting date from external table

    Hello all,
    I am getting the follwing error while selecting data from external table. Any idea why?
    SQL> CREATE TABLE SE2_EXT (SE_REF_NO VARCHAR2(255),
      2        SE_CUST_ID NUMBER(38),
      3        SE_TRAN_AMT_LCY FLOAT(126),
      4        SE_REVERSAL_MARKER VARCHAR2(255))
      5  ORGANIZATION EXTERNAL (
      6    TYPE ORACLE_LOADER
      7    DEFAULT DIRECTORY ext_tables
      8    ACCESS PARAMETERS (
      9      RECORDS DELIMITED BY NEWLINE
    10      FIELDS TERMINATED BY ','
    11      MISSING FIELD VALUES ARE NULL
    12      (
    13        country_code      CHAR(5),
    14        country_name      CHAR(50),
    15        country_language  CHAR(50)
    16      )
    17    )
    18    LOCATION ('SE2.csv')
    19  )
    20  PARALLEL 5
    21  REJECT LIMIT UNLIMITED;
    Table created.
    SQL> select * from se2_ext;
    SQL> select count(*) from se2_ext;
    select count(*) from se2_ext
    ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-04043: table column not found in external source: SE_REF_NO
    ORA-06512: at "SYS.ORACLE_LOADER", line 19

    It would appear that you external table definition and the external data file data do not match up. Post a few input records so someone can duplicate the problem and determine the fix.
    HTH -- Mark D Powell --

  • Cartesian of data from two tables with no matching columns

    Hello,
    I was wondering – what’s the best way to create a Cartesian of data from two tables with no matching columns in such a way, so that there will be only a single SQL query generated?
    I am thinking about something like:
    for $COUNTRY in ns0: COUNTRY ()
    for $PROD in ns1:PROD()
    return <Results>
         <COUNTRY> {fn:data($COUNTRY/COUNTRY_NAME)} </COUNTRY>
         <PROD> {fn:data($PROD/PROD_NAME)} </PROD>
    </Results>
    And the expected result is combination of all COUNTRY_NAMEs with all PROD_NAMEs.
    What I’ve noticed when checking query plan is that DSP will execute two queries to have the results – one for COUNTRY_NAME and another one for PROD_NAME. Which in general results in not the best performance ;-)
    What I’ve noticed also is that when I add something like:
    where COUNTRY_NAME != PROD_NAME
    everything is ok and there is only one query created (it's red in the Query plan, but still it's ok from my pov). Still it looks to me more like a workaround, not a real best approach. I may be wrong though...
    So the question is – what’s the suggested approach for such queries?
    Thanks,
    Leszek
    Edited by xnts at 11/19/2007 10:54 AM

    Which in general results in not the best performanceI disagree. Only for two tables with very few rows, would a single sql statement give better performance.
    Suppose there are 10,000 rows in each table - the cross-product will result in 100 million rows. Sounds like a bad idea. For this reason, DSP will not push a cross-product to a database. It will get the rows from each table in separate sql statements (retrieving only 20,000 rows) and then produce the cross-product itself.
    If you want to execute sql with cross-products, you can create a sql-statement based dataservice. I recommend against doing so.

  • Is there any way to work on one Catalog from two computers simultaenously?

    Is there any way to work on one Catalog from two computers simultaenously?
    I have a catalog with 7000 images we have to process / crop / etc. and I was trying to find a way that two of us could work on the images at the same time.
    Thanks!

    No, the LR catalog is not multi user capable (and cannot reside on a network share without tricks). What you could do is
    export part of the catalog (a subset of all images) into a separate catalog ("Export as Catalog", without exporting the negatives)
    work on different images in the two catalogs at the same time
    re-import ("Import from Catalog") the exported work after adjustments on it is finished
    Beat

  • How to use for all entires clause while fetching data from archived tables

    How to use for all entires clause while fetching data from archived tables using the FM
    /PBS/SELECT_INTO_TABLE' .
    I need to fetch data from an Archived table for all the entries in an internal table.
    Kindly provide some inputs for the same.
    thanks n Regards
    Ramesh

    Hi Ramesh,
    I have a query regarding accessing archived data through PBS.
    I have archived SAP FI data ( Object FI_DOCUMNT) using SAP standard process through TCODE : SARA.
    Now please tell me can I acees this archived data through the PBS add on FM : '/PBS/SELECT_INTO_TABLE'.
    Do I need to do something else to access data archived through SAP standard process ot not ? If yes, then please tell me as I am not able to get the data using the above FM.
    The call to the above FM is as follows :
    CALL FUNCTION '/PBS/SELECT_INTO_TABLE'
      EXPORTING
        archiv           = 'CFI'
        OPTION           = ''
        tabname          = 'BKPF'
        SCHL1_NAME       = 'BELNR'
        SCHL1_VON        =  belnr-low
        SCHL1_BIS        =  belnr-low
        SCHL2_NAME       = 'GJAHR'
        SCHL2_VON        =  GJAHR-LOW
        SCHL2_BIS        =  GJAHR-LOW
        SCHL3_NAME       =  'BUKRS'
        SCHL3_VON        =  bukrs-low
        SCHL3_BIS        =  bukrs-low
      SCHL4_NAME       =
      SCHL4_VON        =
      SCHL4_BIS        =
        CLR_ITAB         = 'X'
      MAX_ZAHL         =
      tables
        i_tabelle        =  t_bkpf
      SCHL1_IN         =
      SCHL2_IN         =
      SCHL3_IN         =
      SCHL4_IN         =
    EXCEPTIONS
       EOF              = 1
       OTHERS           = 2
       OTHERS           = 3
    It gives me the following error :
    Index for table not supported ! BKPF BELNR.
    Please help ASAP.
    Thnaks and Regards
    Gurpreet Singh

  • How to pass the text from a table to the field label on the selection scre

    hi guru's
      i have requirement were in i have to pass the text from a table as field label for
       a input field on the selection screen.
      EX:    selection screen  
                (xxxxxxx )  __________   
                field label    
      please help 
    regards,
    vara

    hi all,
    can you please check the code, and suggest am i doing wrong any were.
    types: xtab(200).
    data : ttab type table of xtab,
    w_so type xtab.
    data: routine(32) value 'TEMP_ROUTINE',
    program(8),
    message(128),
    line type i.
    AT SELECTION-SCREEN OUTPUT.
    select field text DATA_ELEMENT from zauthgrptxt into table t_fieldlabel where STARALLOWED EQ c_asteriks.
    DESCRIBE TABLE t_fieldlabel LINES N.
    w_so = 'REPORT ZTEMP_PROGRAM.'.
    append w_so to ttab.
    w_so = 'FORM TEMP_ROUTINE.'.
    append w_so to ttab.
    loop at t_fieldlabel.
    w_field = t_fieldlabel-field.
    CONCATENATE 'SELECT-OPTIONS: ' ' P_' w_field zspace ' FOR ' ' T_FIELDLABEL-' w_field ' NO INTERVALS NO-EXTENTION.' INTO w_so.
    append w_so to ttab.
    endloop.
    w_so = 'ENDFORM.'.
    append w_so to ttab.
    generate subroutine pool ttab name program
    message message
    line line.
    if sy-subrc = 0.
    perform (routine) in program (program).
    else.
    write:/ Message.
    endif.
    The sy-subrc = 4. nothing is coming into 'program' at generate subroutine pool
    very urgent requirement please help
    thanks,
    vara

Maybe you are looking for

  • How to limit the number of items that a list control can hold?

    Hi, I am using a Flex3 List control for one of my projects. I add drag & drop functionality to it, so that i can drag & drop elements from one control to another. How to limit the number of items that a list control can hold / can be dropped in a lis

  • "Current assignment" field missing in Handling Unit status tab

    Our scenario is as below: 1. STO created and outbound deliveries generated 2. Deliveries are assigned to shipment 3. Packing is done using RF transaction In the normal scenario, the HU status tab would show the outbound delivery number in the current

  • "Insecure Page" Pop-Down on Safari 6.1

    I am getting a pop-down on Safari v6.1 that says my authorize.net credit card submission page is insecure, even though it is https with a lock icon. No such warning on Firefox. Also cannot log in to my merchant services on Safari but can on Firefox.

  • System error 5 has occured

    Hi, I am using Oracle 10g database express edition in windows vista business. While i am trying to strat the database it shows error as "system error 5 has occured" and whenever i am trying to connect the databse from SQL * PLUS it thrown error . err

  • IPhone 4S Calendar

    Does anyone else not have the "+" to add event to the calender on the white IPhone 4S?