SQL Join help for multiple values in single field.

Hello All,
I need a help, I have two tables T1 and T2
Content of T2 will be like
T2. ID | T2.USERNAME
ID1 | John
ID2 | Peter
ID3 | Mark
Content of T1 is like
T1.ID
ID1 ID2 ID3
ID2
ID1 ID3
I need to join these two tables and replace the T1.ID values with T2.USERNAME, for eg. Row one of T1 should be changed as John Peter Mark.
Note: ID1 ID2 ID3 is a single value.
Thanks for your help.
Sathish.

At Volder: I have made a slight enhancement. It's the same thing but the other way around as last week's regular expression thread. Remember the "and then the bird flew away"? ;-)
SQL> create table t1
  2  as
  3  select 'ID1 ID2 ID3' id from dual union all
  4  select 'ID2' from dual union all
  5  select 'ID1 ID3' from dual union all
  6  select 'ID11 ID2' from dual
  7  /
Tabel is aangemaakt.
SQL> create table t2
  2  as
  3  select 'ID1' id, 'John' username from dual union all
  4  select 'ID2', 'Peter' from dual union all
  5  select 'ID3', 'Mark' from dual union all
  6  select 'ID11', 'Volder' from dual
  7  /
Tabel is aangemaakt.
SQL> select * from t1
  2   model
  3    reference r on (select t2.*, rownum rn from t2)
  4     dimension by (rn)
  5     measures(id, username)
  6    main m
  7     dimension by (id)
  8     measures(cast(id as varchar(200)) str)
  9     rules iterate(100) until (r.id[iteration_number+1] is null)
10      (str[any] = replace(str[CV()], r.id[iteration_number+1],r.username[iteration_number+1]))
11  /
ID          STR
ID1 ID2 ID3 John Peter Mark
ID2         Peter
ID1 ID3     John Mark
ID11 ID2    John1 Peter
4 rijen zijn geselecteerd.
SQL> select id
  2       , str
  3    from t1
  4   model
  5         reference r on (select id,username,rownum rn from t2)
  6           dimension by (rn)
  7           measures (id, username)
  8         main m
  9           dimension by (id)
10           measures (cast(' ' || id || ' ' as varchar2(200)) str)
11           rules iterate(1000) until (r.id[iteration_number+1] is null)
12           ( str[any] = replace
13             ( str[cv()]
14             , ' ' || r.id[iteration_number+1] || ' '
15             , ' ' || r.username[iteration_number+1] || ' '
16             )
17           )
18  /
ID          STR
ID1 ID2 ID3  John Peter Mark
ID2          Peter
ID1 ID3      John Mark
ID11 ID2     Volder Peter
4 rijen zijn geselecteerd.At Sathish: just look at the queries we have to come up with to do such a simple thing. As said many times before, I would also encourage you to change the design instead of executing the queries presented by Volder and me.
Regards,
Rob.
Message was edited by:
Rob van Wijk
Just noticed I missed a final TRIM function around "str", so please add this.

Similar Messages

  • SQL Command code for multiple value string parameter

    Hi,
    I'm using crystal 2008 and there is a check box for multiple value  SQL Command  I need some help in writing the SQL Command code  for oracle (or sql server) for a multiple value STRING  parameter.
    Thanks in advance,
    Marilyn

    I could be wrong here, but I do not believe you can pass a multiple valued parameter to an SQL Command data source.  How I have gotten around this in the past is to put the "real" report into a subreport.  In the main report, create a formula field (basic syntax):
    formula = join({?parameter}, "|")
    Then, use this to pass the selected values to the subreport's parameter (call it {?sr-parm}).  The SQL Command in the subreport can then use that (MS SQL):
    select *
    from table
    where charindex(table.field, '{?sr-parm}') > 0
    HTH,
    Carl

  • Pass Multiple values of single field to ITS url

    Hi ,
    I have one transaction code(YW37P),
    I that have one field(Order No) in the selection screen, which has capable to accept multiple values (i.e multiple single values) and excute the t code.
    Now my question is how to pass this multiple values of one single field to the ITS url and by pass the selection screen.
    I have gone through the blogs which explains about how to pass only one single value of single field to ITS url and by pass the selection screen
    please provide some solution for this
    Regards
    Srinivas

    Hello Srinivas,
    How do you enter multiple order numbers in the field usually?  Is there a space or comma separating the numbers?  If so you will probably need to encode the space or comma, ie if a comma %2C.  The easiest way to figure it out is to use a tool like HTTPwatch and capture the POST data to see the value that is normally sent by the transaction. 
    Edgar

  • Enhancing standard (single select)search help for Multiple value selection

    Hi,
    Standard search help for Business Partner (in cProjects) allows only single value selection for input fields. I want to make this multiple selection.
    Is there a way to do it.
    I used an OVS and built a similar search but its difficult to get the standard options like saving to personal value list etc in it.
    It would be good if there is a way to modify the standard search help to allow multiple selection. Any ideas??
    Appreciate your help,
    Thanks,
    Sri
    Edited by: Sri on Sep 9, 2010 8:50 PM
    Edited by: Sri on Sep 9, 2010 8:52 PM

    As far as I know you can't make a standard ABAP dictionary search help return multiple entries - where you get this sort of functionality the searches don't use the standard Elementary search help framework (e.g. organisational structure searches)
    Given that the WDA search help relies on these dictionary based searches, I'd think very much that you couldn't enhance it to return multiple. how you could even return multiple entries into a single UI element input field is also confusing to me.
    I'd suggest creating a freely programmed value help, it would certainly take quite some effort to recreate those personal value lists etc, but it could be done - I don't like OVS, but that just me.

  • Multiple records to be created for multiple values in a field

    I am having a requirement in which i will have multiple values for a field.The values are seperated by commas.I need a record to be created for each value.(eg: if there are 4 values i need 4 records to be created). Any one please help me out.

    Hi !
    You can try solve it at File Content Conversion level, by specifing your value separator as the endSeparator.
    Or you can import all values as a unique record and then solve it via graphical mapping, using an advanced UDF, where you receive N records, then inside the UDF, you split the values via its separator and create new array values (one for each input value after splitting) and output that array to be used to fill destination structure.
    Regards,
    Matias.

  • Excel cells appear garbled; either multiple values in single field or problem with redrawing of the cells.

    In editing a simple, new Excel 2013 file, I am seeing certain cells with multiple, overlapping values in the a single cell.  This is in the A-column so, not a matter of margins.  Specificially, in one cell, I had "Design", then replaced
    that text with "Reqt".  Now I see the word "Reqt" written over "Design".  when trying to delete the values, I can remove the "Reqt" value, but the "Design" value will not disappear/delete.
    I've tried saving and reopenning the file with no effect; problem persists.  Makes me think this is a corrupted .xlsx file, even though I just started from scratch 15 minutes before the problem arose.
    I appreciate any guidance (or bug submission) you can support.
    V/R,
    Kevin

    I have successfully inserted seven records in one form submit operation by looping through the command object execute method.
    However, the data that is being inserted by the command object is repetition of the first record and the command object is not taking any data from the text boxes for the second record onwards. In this I had used the isert record behavious generated by DW CS4 and modified it to suit my requirement. However, the data inserted in the first row is getting repeated in all the seven rows.
    Please help.
    Also advise if there are any free dreamweaver server side validation extensions available.

  • SPGridView with filtering on Taxonomy Field Multivalue column( column with multiple values in single row)

    Hi
    I have SPGridView  control (fetching value from DB) with a column which is having multiple values
    in single row seperated by ";", whenever filter applied it show these values in single row but i want
    to dispaly these values separately in diff. rows when column filter is applied.
    I have exactly same req. as mentioned in http://sadomovalex.blogspot.in/2011/03/spgridview-with-filtering-by-multiple.html
    but this solution didn't work for me.
    Please help/suggest.

    Hi Erland,
    Thank you very much for the answer. Sorry I had to be more accurate on my XML : This XML is in a SQL Server Table column. This table also has an id column. It will be great if you can answer specifically to this.
    <RootNode>
    <Node1>
    <Line_id_Node>1 </Line_id_Node>
    <A>
    <B>
    <D>Val1 </D>
    </B>
    <B>
    <D>Val2 </D>
    </B>
    <B>
    <D>Val3 </D>
    </B>
    </A>
    </Node1>
    <Node1>
    <Line_id_Node> 2 </Line_id_Node>
    <A>
    <B>
    <D>Val4 </D>
    </B>
    <B>
    <D>Val2 </D>
    </B>
    </A>
    </Node1>
    <Node1>
    <Line_id_Node> 3 </Line_id_Node>
    <A>
    <B>
    <D>Val5 </D>
    </B>
    </A>
    </Node1>
    </RootNode>
    Expected O/P:
    Line_id_Node                Column_D
    1                                                                    1                                           
    val1, val2, val3
    2                                                                    2                                               
    val4, val2
    3                                                                    3                                                  
    val5
    Nichesl

  • Pass multiple values as single input parameter into pipelined function

    Hi all,
    My need is to pass multiple values as single input parameter into pipelined function.
    For example - "2" and "3" are values of input parameter "t":
    with data as (
    select 1 as t from dual union all
    select 2 as t from dual union all
    select 3 as t from dual union all
    select 4 as t from dual union all
    select 5 as t from dual
    select * from data where t in (2,3)Is it possible at all?

    Not exactly sure, but usually 'multiple values'+'pipelined function' = some IN-LIST related approach?
    See:
    SQL> create table data as
      2  select 1 as t from dual union all
      3  select 2 as t from dual union all
      4  select 3 as t from dual union all
      5  select 4 as t from dual union all
      6  select 5 as t from dual;
    Table created.
    SQL> --
    SQL> CREATE OR REPLACE FUNCTION in_list (p_in_list  IN  VARCHAR2)
      2  RETURN sys.odcivarchar2list PIPELINED
      3  AS
      4    l_text  VARCHAR2(32767) := p_in_list || ',';
      5    l_idx   NUMBER;
      6  BEGIN
      7    LOOP
      8      l_idx := INSTR(l_text, ',');
      9      EXIT WHEN NVL(l_idx, 0) = 0;
    10      PIPE ROW (TRIM(SUBSTR(l_text, 1, l_idx - 1)));
    11      l_text := SUBSTR(l_text, l_idx + 1);
    12    END LOOP;
    13 
    14    RETURN;
    15  END;
    16  /
    Function created.
    SQL> --
    SQL> select *
      2  from   data
      3  where  t in ( select *
      4                from   table(in_list('1,2'))
      5              );
             T
             1
             2
    2 rows selected.http://www.oracle-base.com/articles/misc/dynamic-in-lists.php
    or
    http://tkyte.blogspot.nl/2006/06/varying-in-lists.html

  • One search help for multiple select-options in webdynpro abap

    Hi,
    I need a way to use one search help for multiple select-options fields. My scenario is :
    I have a table for keeping different organizational units' values of different systems. I have pasted some sample data from this table at the end of this mail. On the screen I want to have 1 select-options filed for werks, and 1 select-options filed for vkorg. (In fact I will have more org. unit fields...) In the beginning of my application the user will select sid.
    If the user selects ADS as SID, when he opens search-help for the first org. unit (werks), he will see the records with SID: ADS, VARBL = $WERKS, LANGU = SY-LANGU.
    If the user selects AGT as SID, when he opens search-help for the second org. unit (vkorg), he will see the records with SID: AGT, VARBL = $VKORG, LANGU = SY-LANGU.
    I have created a search-help taking SIDD, VARBL and LANGU as import parameters; used field mapping and bound this search help to my table. I have created 2 context nodes : org1 and org2 having attributes SID, VARBL, VALUE, LANGU .
    I have assigned related SID, VARBL and Langu values to these attributes at runtime as I needed. That way, if I use input field and reference to the related context attributes org1-value and org2-value2 accordingly, search help works well as I want.
    However, when I use select-options field , I can not bind the field to the context data. I can give reference only to ddic structure. Is there any way to reference to a context attribute? I searched for this in SDN, but could find nothing.
    I think I won't be able to use this way. What do you say?
    As I read from forums maybe using OVS help will be suitable for me. But I have to use one search-help for all select-options fields. Do you know how I can determine the active select-options field and pass its name (for instance "werks" ) as parameter to this OVS search help. (Also I'll pass SID and LANGU.)
    MY TABLE (ZBYYT080) CONTENTS:
    SID     VARBL     VALUE     LANGU     VTEXT
    ADS     $WERKS     1     T     Werk 0001
    ADS     $WERKS     11     T     OZYAS  GIDA URETIM YERI
    ADS     $WERKS     5501     T     BOYA GEBZE FABRİKASI
    ADS     $WERKS     5502     T     BOYA CIGLI FABRİKASI
    AGT     $WERKS     2301     T     KAMLI DAMIZLIK
    AGT     $WERKS     9601     T     PANAR DENIZ URETIM YERI
    ADS     $VKORG     22     T     AA KİMYASALLAR
    ADS     $VKORG     8001     T     İINSAAT BOYALARI
    AGT     $VKORG     6500     T     DAMk St.Org
    AGT     $VKORG     5400     T     PANAR St.Org.
    I wish I'm clear enough..
    I will be gald if someone answers me as soon as possible...
    Thanks İn advance..
    MERAL

    Hi,
    Your ques is how to refer to a DDIC search help to refer to selection screen parameter ?
    Am I right ?
    If Yes, then in the interface IF_WD_SELECT_OPTIONS
    method ADD_SELECTION_FIELD, ADD_PARAMETER_FIELD etc
    have importing param like I_VALUE_HELP_TYPE and  I_VALUE_HELP_ID, I_VALUE_HELP_MODE, I_VALUE_HELP_STRUCTURE
    etc which may help you to link your create DDIC Search help to selection screen params.
    this is just a clue from my side. I haven't tried it myself.
    You can go to the where used list of this method and find some sample implementations which use these params.
    Hope this helps.
    Regards
    Manas Dua

  • How to search for multiple values with Bex Prompts

    Hi,
    I would like to know  if it is possible to search for multiple values at the same time with Bex Prompts instead of searching one value at a time (please see the screen shot below). I searched the forum couldn't find any relevant answers. please let me know  how  to achieve?
    Thanks,
    Charvi.

    Hi Charvi,
    You can use wild card search to ensure you get multiple similar values listed as search output.use * for multiple characters and ? for single character.
    For Example, Ravi * would result you all employees with first name as Ravi
    You can use various search formats such as * Ravi * and * Ravi and Ra?? etc.
    Thanks
    Mallik

  • Query for multiple row to single

    Hi All,
    Need help in Multiple row to single row
    create table cust_tranc_track
    (id number,
    payment_dt date ,
    emi_dt date,
    appr_dt date
    SET DEFINE OFF;
    Insert into CUST_TRANC_TRACK
       (ID, APPR_DT)
    Values
       (425, TO_DATE('11/12/2012 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into CUST_TRANC_TRACK
       (ID, PAYMENT_DT, EMI_DT)
    Values
       (425, TO_DATE('11/01/2012 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('11/13/2012 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    COMMIT;
    Output :
    ID     PAYMENT_DT     EMI_DT              APPR_DT
    425     11/1/2012     11/13/2012     11/12/2012thanks
    ajr

    *> g2500 wrote:**> Hi All,*
    *>*
    *> Need help in Multiple row to single row*
    *>*
    *> *
    *>*
    *>*
    **_+Hi,+_**
    **_+I cant clear about ur question. I m giving the solution wat i can understand.to get multiple row inti single u can use listagg function.+_**
    **_+use hr.employees+_**
    **_+select department_id,listagg(first_name,',') WITHIN GROUP (ORDER BY first_name) AS employeename+_**
    **_+from employees+_**
    **_+group by department_id;+_**
    **_+u [http://dba-oracle.com/t_oracle_listagg_function.htm]+_**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • SetSelectedValue for multiple values in List Box

    Hi,
    I want to set the selectedValue for multiple values in the List Box. If i use setSelectedValue for all the values, it just highlights the last one.
    Can anyone tell me how do i highlight multiple values in the List Box?
    Scenario:
    I have one screen where the List Box and "Go" button is placed. When i select multiple values in the list box and hit "Go" it should display what i have selected in the List Box.
    Note: List Box is generated dynamically.
    Thanks,
    Naresh V

    setSelectedValue as the name indicates will set one value and in your case since you are using it multiple times it would pick the last value.
    When the user selects multiple values from the list box and clicks on Go you can capture those values in the controller for processing. What are you trying to achieve by resetting all the selected values on the same listbox ?

  • Dynamic where clause for MULTIPLE values

    In the following of dynamic where clause?
    i have some somewhat different problem.
    Is a dynamic where clause for multiple values possible?
    If the inputvariable varCode1,varCode2,varCode3,varCode4 are 0 then show all id's otherwise filter the resultset on var1 and/or var2,and/or var3,and/or var4.
    Example table:
    create table t
    (d int,var int);
    insert into t values (1 ,1 );
    insert into t values (2 ,1 );
    insert into t values (3 ,2 );
    insert into t values (4 ,3 );
    insert into t values (5 ,4 );
    insert into t values (6 ,4 );
    insert into t values (7 ,4 );
    insert into t values (8 ,4 );
    insert into t values (9 ,5 );
    insert into t values (10, 6);
    insert into t values (11, 6);
    So what i want to change the where clause upon the value of the varCodes. If var1 and var are not 0 a "AND" should be used otherwise an "OR"
    select id
    from tst
    where var = DECODE( :varCode1, 0, var, :varCode1)
    or/and(?) DECODE( :varCode2, 0, var, :varCode2)
    or DECODE( :varCode3, 0, var, :varCode3)
    or DECODE( :varCode4, 0, var, :varCode4)

    Please turn off your Caps Lock
    and try this link
    Dynamic WHERE clause

  • Extended Program check for multipl programes in single run

    Hello All,
    I wan to do the syntax check for multiple programs at single execution run.
    SAP has provided SLIN transaction for single program, Is there any SAP standard transaction similar as SLIN for multiple program check at single execution run?
    Thanks,
    Feroz.

    >
    s feroz wrote:
    > I need it in R/34.6b version.
    I don't think you have much option there

  • Query for multiple value search

    Hi
    I got struck when I try to construct SQL query to fetch multiple values in WHERE clause.
    SELECT columnName from someTable
    WHERE someValue = {here is the problem, I have multiple values here which I get from some array}
    Is there any way I can put multiple values to where clause?

    here we go
    this????
    SQL> var LIST varchar2(200)
    SQL> EXEC :LIST := '10,20';
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.00
    SQL>  SELECT items.EXTRACT('/l/text()').getStringVal() item
      2   FROM TABLE(XMLSEQUENCE(
      3   EXTRACT(XMLTYPE('<all><l>'||
      4   REPLACE(:LIST,',','</l><l>')||'</l></all>')
      5  ,'/all/l'))) items;
    ITEM
    10
    20
    Elapsed: 00:00:00.04
    SQL> ed
    Wrote file afiedt.buf
      1  SELECT empno,
      2         ename
      3    FROM emp
      4   WHERE dno IN (SELECT items.EXTRACT ('/l/text()').getStringVal () item
      5                   FROM TABLE (XMLSEQUENCE (EXTRACT
      6*                   (XMLTYPE ('<all><l>' || REPLACE (:LIST, ',', '</l><l>') || '</l></all>'), '/all/l') ) )
    SQL> /
         EMPNO ENAME
          7934 MILLER
          7839 KING
          7782 CLARK
          7902 FORD
          7876 ADAMS
          7788 SCOTT
          7566 JONES
          7369 SMITH
    8 rows selected.

Maybe you are looking for