Join 2 tables, One to many, but single row only

I have a table (actually it is a view) with detail information.
I want to join to that table, but for my join criteria, bring back no more than 1 row. This is because there is some data on the table which is consisitent on each row so any row of my join will do.
ie.
select list.invoice_number, inv.payment_terms
from
list, inv
where list.invoice_number=inv.invoice_number(+)
LIST
Invoice Number
1
2
3
4
INV
Invoice Number, Seq, Payment_terms
1               1    30
1               2    30
1               3    30
2               1    40
2               2    40
3               1    50would produce
Invoice Number, Payment_terms
1               30
2               40
3               50
4Thanks

Would there be more than one value for payment_terms in inv? If so, then the distinct is probably the way to go, although I would probably do the DISTINCT in an in-line view like:
SELECT list.invoice_number, inv.payment_terms
FROM list,
     (SELECT DISTINCT invoice_number, payment_terms
      FROM inv) inv
WHERE list.invoice_number=inv.invoice_number(+)If each invoice would only ever have one value for payment_terms, then I might try an in-line view like:
SELECT list.invoice_number, inv.payment_terms
FROM list,
     (SELECT invoice_number, MAX(payment_terms) payment_terms
      FROM inv
      GROUP BY invoice_number) inv
WHERE list.invoice_number=inv.invoice_number(+)On the other hand, if inv is a view based on a multitable join, I would also check to see if incoice_number and payment_terms come from the same table. If so, I would be tempted to write your query using the base tables instead of the view since it is likely to bve more efficient.
John

Similar Messages

  • Allow for more than ONE item in a single row?

    Allow for more than ONE item in a single row? I can't use this wonderful program unless I can get more than one field on a row (i.e. 1st name, mi, last name etc)

    Thanks for your feedback. This is something we definetely want to provide next year (can't say when yet).
    If others are interested in this feature please vote on it within the idea tab: http://forums.adobe.com/ideas/1046
    That helps us prioritize our work based on customer demand.
    Randy

  • HT201210 hi , this iphone is change new one to me, but i use only 1 day it broken again ! i can not restored

    hi , this iphone is change new one to me, but i use only 1 day it broken again ! i can not restored
    Model A1429
    Imei  : 013717001187438
    Sirim No. RAXF/63B/1012/S(12-1823)
    Notis - An unknown error occurred (14)

    It seems the iPhone before the update was not officially unlocked from the carrier it is locked to. Which would mean it had been unlocked to use on your carriers sim by jailbreaking(hacking) or by using third party hardware.

  • Joining two tables, 1 to many relation

    I would like to run a query on two tables, connected with a join.
    Table A contains a user_name and a user_network_name, the rows are unique.
    Table B contains a user_name and a date/time of logon, there a many rows for one user name.
    I would like to join the tables, with the restriction that in the results only the most recent date/time of logon per user_name appears.
    How do I write the query for that ?
    Kind regards,
    Dirk

    Hi,
    If you did not get the answer yet, then please post DDL+DML instead of stories. What I mean is that instead of trying to describe your database structure, you should post (1) queries to create you relevant tables, (2) queries to insert those tables some
    sample data for us to work with, and talk about if needed. Part 1 named DDL and part 2 named DML :-)
    With this information people can reproduce your situation and give you a solution after they checked it. After all we can not query a story (description) but only tables.
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • Joining 18 tables -- one at a time or in two stages ?? best one..??

    I have to join 18 tables,.. Is it best to join all 18 in a single shot or to go with
    multi stages-- 9 tables in one stage and after that anotther 9 tables..
    Please anyone give me a good suggestion on this with some reason...
    Thanks in advance

    If you can look at your query and recognise that it is trying to collect (say) two small result sets and then join the result sets, then it is actually a good idea to express the query in that fashion to Oracle.
    Take for example a query that sums last week's profits for a supermarket by department using a 9 table query in about 2 minutes. A similar query reports the previous week's profits with a marginally different query in about two minutes. You write the two queries as inline views and join them to report the percentage change in profit by department - and the query takes 4 hours because Oracle has used "complex view merging" to turn your two 9-table queries into a single 18-table query.
    In this case, a workaround is to use the /*+ no_merge */ hint. In outline, something like:
    select     {columns}
    from
         select /*+ no_merge */
              dept_no,
              etc.
         from     ...
         )     lw,
         select /*+ no_merge */
              dept_no,
              etc.
         from     ...
         )     pw
    where
         pw.dept_no = lw.dept_no
    ;In less obvious cases you may still be able to find that you can break up a big query into a few smaller, logical sections, and use this technique to generate and join what are, in effect, intermediate results.
    An alternative to the /*+ no_merge */ hint is to use subquery factoring to the same end. There's a more complex example of the method here: http://jonathanlewis.wordpress.com/2007/07/01/internet-sql/
    In either case, avoid turning your 18-table query into 18 separate pieces and sticking them back together - it may make the optimizer do some very silly things. Karen Morton mentions an example of this on her blog: http://karenmorton.blogspot.com/2008/06/dont-do-work-you-dont-have-to-do.html
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    "The greatest enemy of knowledge is not ignorance,
    it is the illusion of knowledge." (Stephen Hawking)

  • How to resolve many-to-many join by 2 one-to-many joins

    Hi,
       I was asked many times how to resolve many to many relationship between two tables. I read to use 2 one -to- many relationships to resolve this. Can some expalin me when many to many relationship occurs between two tables and how to reslove them with practicle examples. Is there any article on this?
    Regards,
    Nanda Kishore

    Hi,
    Please check below link.
    http://www.forumtopics.com/busobj/viewtopic.php?p=859029&sid=20d79e3df07b0d8b41aadfbd902bb6b2
    http://blog.oaktonsoftware.com/2011/04/bridge-tables-and-many-to-many.html
    Thanks,
    Amit

  • I want to join the table vbrk,vbrp,konv but konv is cluster table .

    Hi
       konv is the cluster table . so   I  want to join the table vbrk,vbrp,konv and fields are vbeln, knumv is possible .
    if it isn't possible. what is the another method output is doc. no.(vbrp-vbeln) condition doc. no.(vbrk-knumv) , condition(konv-kschl), tax rate(konv-mwsk1), quantitty(vbrp-fkimg) .reply pls... as soon as possible..

    hi
    good
    1) Open
        Select
               Mard~matnr
               Makt~maktx
          From Makt
          Inner Join Mard
          on    Maktmatnr = Mardmatnr
          Where Makt~Spras = SY-LANGU
    2) Native Oracle
          SELECT Mard.matnr,
                 Makt.maktx
          From Makt, Mard
          Where Makt.mandt = Mard.mandt
            And Makt.matnr = Mard.matnr
            And Makt.mandt = :SY-MANDT
            And Makt.spras = :SY-LANGU
    3) KONV is Cluster - BAD LUCK!
        Select VBRK~VBELN
               VBRP~POSNR
               KONV~KSCHL
               KONV~KWERT    
          From ( VBRK Inner Join VBRP
                 On VBRKVBELN = VBRPVBELN )
               Inner Join KONV
                 On  VBRKKNUMV = KONVKNUMV
                 And VBRPPOSNR = KONVKPOSN
    4) KONV is Cluster - BAD LUCK!
        Select KONV~KNUMV
               KONV~KPOSN
               KONV~KSCHL
               KONV~KWERT    
          From KONV
          Where KONV~KNUMV in (
               Select VBRK~KNUMV
                 From VBRK Inner Join VBRP
                 On VBRKVBELN = VBRPVBELN
                Where VBRKKNUMV = KONVKNUMV
                  And VBRPPOSNR = KONVKPOSN
    5) Open
             Select VBRP~MATNR
                    Sum( VBRP~NETWR )
              From VBRP
              Group By VBRP~MATNR 
    6) Native Oracle        
             Select VBRP.MATNR ,
                    Sum( VBRP.NETWR )
              From VBRP
              Where mandt = :sy-mandt
              Group By VBRP.MATNR         
    7) Native Oracle
             Select VBRP.MATNR ,
                    Count( VBRP.NETWR ),
                    Sum( VBRP.NETWR )
              From VBRP
              Where mandt = :sy-mandt
              Group By VBRP.MATNR    
    8) Open
             Select VBRP~MATNR
                    makt~maktx
                    Sum( VBRP~NETWR )
              From VBRP inner Join MAKT
                On VBRPMATNR = MAKTMATNR
              Where MAKT~SPRAS = SY-LANGU
              Group By VBRPMATNR maktmaktx      
    9) Native Oracle         
             Select VBRP.MANDT,
                    VBRP.MATNR,
                    MAKT.MAKTX,
                    Sum( VBRP.NETWR )
              From VBRP , MAKT
             Where  VBRP.MANDT = MAKT.MANDT
               And  VBRP.MATNR = MAKT.MATNR
               And  MAKT.SPRAS = :SY-LANGU
              Group By VBRP.MANDT, VBRP.MATNR, MAKT.MAKTX   
    10) Open          
         SELECT EKET~EBELN 
                EKET~EINDT 
                EKET~WAMNG 
                EKET~WEMNG 
          From  ( ekko INNER JOIN ekpo
                  ON  ekkomandt = ekpomandt
                  AND ekkoebeln = ekpoebeln
                INNER JOIN eket
                ON  ekpomandt = eketmandt
                AND ekpoebeln = eketebeln
                AND ekpoebelp = eketebelp
                AND EKET~WAMNG > 0
                AND EKETWAMNG <> EKETWEMNG
         Where EKPO~MATNR = 'NB220'
           And EKPO~WERKS  In ('P001', 'P004', 'L004')
           And EKKO~BSTYP = 'F'
           And EKKO~BSART = 'UB'
           And EKPO~ELIKZ <> 'X'
           And EKKO~LOEKZ <> 'X'     
    11) Native Oracle      
         SELECT EKET.EBELN, 
                EKET.EINDT, 
                EKET.WAMNG, 
                EKET.WEMNG 
          FROM  ( ekko INNER JOIN ekpo
                  ON  ekko.mandt = ekpo.mandt
                  AND ekko.ebeln = ekpo.ebeln
                INNER JOIN eket
                ON  ekpo.mandt = eket.mandt
                AND ekpo.ebeln = eket.ebeln
                AND ekpo.ebelp = eket.ebelp
                AND EKET.WAMNG > 0
                AND EKET.WAMNG <> EKET.WEMNG
         Where EKPO.MATNR = 'NB220'
           And EKPO.WERKS  In ('P001', 'P004', 'L004')
           And EKKO.BSTYP = 'F'
           And EKKO.BSART = 'UB'
           And EKPO.ELIKZ <> 'X'
           And EKKO.LOEKZ <> 'X'
    thanks
    mrutyun^

  • Workbench-Cannot Give Joining to One-To-Many

    Hi there,
    i am using toplink workbech 10g release 2(10.1.3.0DP4) build 050715. In workbench, i want to put "use joining" to a one-to-many relationship. Joining can be applied to one-to-many relationships from the java code but in workbench i cannot give joining to the one-to-many relationships. There is no checkbox for that property. I can only check batch reading. Is it true, or is there a problem with my mapping workbench?

    This is true, there is currently no 1-m joining support in the Mapping Workbench, nor can you set this at the mapping level in the code API. 1-m joining can only currently be set at the query level in the code API. Note that in general batch reading for 1-m is more performant than joining, so you may want to consider using it instead.

  • How to create one to many relation database based on existing Tables?

    Let say I have got 10 tables. Out of these 10 tables one table is used to navigate to other tables and at the some time providing some useful information. Therefore other 9 Tables have the identical structure.
    The question is, how can I convert these 10 tables into 2 tables, ie each row of first table correspond to the different data of the other table (one to many relation)?

    Hello,
    >>The question is, how can I convert these 10 tables into 2 tables, ie each row of first table correspond to the different data of the other table (one to many relation)?
    I do not quite understand what you ask and I doubt if Entity Framework supports this scenario, since you mentions these tables already exist, after importing them to the designed windows, we cannot modify them or it would throw an error shows the database
    and model is mismatched.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • One to many relationship question.

    Let's say we have table1 and table2
    Table1 has ID, and let's say Name for fields.
    Table2 has ID, and let's say SSN for fields.
    This is not so, but illustrates my points well.
    Table2 has many records with the same ID, who just happen to have the same SSN. That would usually be a logical conclusion.
    Table1 has only 1 of each ID in it. So you might say that ID is a foreign key in table2, except one problem. I don't think they know what primary keys are here, much less foreign keys.
    Anyway, I have to write a query where I get the ID from table1 and need the SSN from table2. That's the only place in this scenario that SSN is.
    My question is this - since this is a one to many relationship, yet I only need 1 result, how would I write this using the (+) way of notation? I am using 8i.
    Right now, I am doing something like this, using a DISTINCT:
    Select DISTINCT t1.ID, t1.Name, t2.SSN
    From table1, table2,
    Where t1.ID = t2.ID (+);
    First of all, is this the correct way of writing it?
    And second, I am wondering if, perchance for some error, there were 2 or more SSNs in table2, what would happen then? Would I get a too many rows error?
    And if so, how can I trap it and possibly get just the first occurrence of it?
    Is that even a sound way of doing it?
    Thanks for any thoughts here.

    You would need to turn your table2 into an in-line view in order to outer join to it properly. Minimally, something like:
    SELECT t1.id, t1.name, t2.ssn
    FROM table1 t1,
         (SELECT DISTINCT id, ssn
          FROM table2) t2
    WHERE t1.id = t2.id(+)If there may be multiple ssn in t2 for a single id, you will need to determine which one you want to keep and use something like:
    SELECT t1.id, t1.name, t2.ssn
    FROM table1 t1,
         (SELECT id, ssn
          FROM (SELECT id, ssn,
                       ROW_NUMBER() OVER (PARTITION BY id,
                                          ORDER BY column_that_makes_it_first) rn
                FROM table2)
          WHERE rn = 1) t2
    WHERE t1.id = t2.id(+)This should work on 8.1.7.4 Enterprise Edition. If you have a different version, then the analytic function may not work so you would need something more like:
    SELECT t1.id, t1.name, t2.ssn
    FROM table1 t1,
         (SELECT id, ssn
          FROM (SELECT id, ssn, rownum rn
                FROM (SELECT id, ssn,
                      FROM table2
                      ORDER BY id, column_that_makes_it_first))
          WHERE rn = 1) t2HTH
    John

  • How to prevent Oracle from using an index when joining two tables ...

    How to prevent Oracle from using an index when joining two tables to get an inline view which is used in an update statement?
    O.K. I think I have to explain what I mean:
    When joining two tables which have many entries sometimes it es better not to use an index on the column used as join criteria.
    I have two tables: table A and table B.
    Table A has 4.000.000 entries and table B has 700.000 entries.
    I have a join of both tables with a numeric column as join criteria.
    There is an index on this column in table A.
    So I instead of
      where (A.col = B.col)I want to use
      where (A.col+0 = B.col)in order to prevent Oracle from using the index.
    When I use the join in a select statement it works.
    But when I use the join as inline view in an update statement I get the error ORA-01779.
    When I remove the "+0" the update statement works. (The column col is unique in table B).
    Any ideas why this happens?
    Thank you very much in advance for any help.
    Regards Hartmut

    I think you should post an properly formatted explain plan output using DBMS_XPLAN.DISPLAY including the "Predicate Information" section below the plan to provide more details regarding your query resp. update statement. Please use the \[code\] and \[code\] tags to enhance readability of the output provided:
    In SQL*Plus:
    SET LINESIZE 130
    EXPLAIN PLAN FOR <your statement>;
    SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);Usually if you're using the CBO (cost based optimizer) and have reasonable statistics gathered on the database objects used the optimizer should be able to determine if it is better to use the existing index or not.
    Things look different if you don't have statistics, you have outdated/wrong statistics or deliberately still use the RBO (rule based optimizer). In this case you would have to use other means to prevent the index usage, the most obvious would be the already mentioned NO_INDEX or FULL hint.
    But I strongly recommend to check in first place why the optimizer apparently seems to choose an inappropriate index access path.
    Regards,
    Randolf
    Oracle related stuff:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle:
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Exemple of join two table

    hi,
    can i find an exmple with ejb3 that joint two tables, bcuz i tried many thing but i couldnt run it.
    and thank you

    i'm trying to join 2 tables (contact and personne) but it didnt succed
    this is my class contact
    package com.labosun.cj.ejb3.entity;
    import java.io.Serializable;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.JoinColumn;
    import javax.persistence.OneToOne;
    * Entity Bean Contact
    * @author Cyril
    @Entity // Annotation indiquant que la classe est un entity bean
    public class Contact implements Serializable{
    private int id;
    private String firstname;
    private String lastname;
    private String address;
    private int zipCode;
    private String city;
    private String phone;
    private String mobile;
    private Personne personne;
    @OneToOne
    @JoinColumn(referencedColumnName="ID")
    public Personne getPersonne() {
    return personne;
    public void setPersonne(Personne personne) {
    this.personne = personne;
    public Contact() {
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    public int getId() {
    return id;
    public void setId(int id) {
    this.id = id;
    }and this is my class personne
    package com.labosun.cj.ejb3.entity;
    import java.io.Serializable;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.JoinColumn;
    import javax.persistence.OneToOne;
    * Entity Bean Contact
    * @author Cyril
    @Entity // Annotation indiquant que la classe est un entity bean
    public class Personne implements Serializable{
    private int id;
    private String firstname;
    private String lastname;
    private Contact contact;
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    public int getId() {
    return id;
    public void setId(int id) {
    this.id = id;
    @OneToOne(mappedBy="personne")
    public Contact getContact() {
    return contact;
    public void setContact(Contact contact) {
    this.contact = contact;
    public String getFirstname() {
    return firstname;
    public void setFirstname(String firstname) {
    this.firstname = firstname;
    public String getLastname() {
    return lastname;
    public void setLastname(String lastname) {
    this.lastname = lastname;
    }et le requete
    em.createQuery("SELECT contact.lastname FROM Contact AS contact JOIN contact.personne AS personne").getResultList(); but no join

  • "Use one as many "function

    Hi All
    I have a scenario from RFC to WSDL in which if certain conditions fulfil only then can I pass the value to the target field "SERVCODE".
    The problem is there are many conditions which are to be fulfilled to have the value passed.
    I tried using the function "use One As Many" but I got stuck at the "OR" condtion because its taking only boolean values.
    Please have a look at the scenario and help me!!
    Also I am preferring to have a graphical mapping but if nothing works out User defined function would do.
    u2022     IF VBAP-PSTYV = Z004 & VBAP-UEPOS <> BLANK & MARA-MATKL = 800001031----
    then  SERVCODE = 400 (400 is the Value to be passed to the target field to SERVCODE)
    u2022     IF VBAP-PSTYV = Z004 & VBAP-UEPOS<> BLANK & MARA-MATKL <> 800001031 & VBAK u2013AUART = Z000 & MVKE u2013 MVGR2 = 001 -
    then   SERVCODE= 201(201is the Value to be passed to the target field  to SERVCODE)
    u2022     IF VBAP-PSTYV = Z004 & VBAP-UEPOS <> BLANK & MARA-MATKL <> 800001031 & VBAK u2013AUART = Z000 & MVKE u2013 MVGR2 = 002 -
    then  SERVCODE= 202 (202 is the Value to be passed to the target field to SERVCODE)
    u2022     IF VBAP-PSTYV = Z004 & VBAP-UEPOS <> BLANK & VBAK u2013AUART = Z001& MVKE u2013 MVGR2 = 001 -
    then SERVCODE= 301(301 is the value to be passed to the target field to SERVCODE)
    u2022     IF VBAP-PSTYV = Z004 & VBAP-UEPOS <> BLANK& VBAK u2013AUART = Z001 & MVKE u2013 MVGR2 = 002 -
    then SERVCODE= 302 (302 is the Value to be passed to the target field to SERVCODE)
    u2022     IF VBAP-PSTYV <> Z004 VBAP-AUART = Z000 -
    then  SERVCODE = 1 (1 is the Value to be passed to the target field to SERVCODE)     
    u2022     IF VBAP-PSTYV <> Z004 VBAP-AUART = Z001 -
    then  SERVCODE = 101(101 is the Value to be passed to the target field to SERVCODE)
    u2022     IF VBAP-PSTYV = Z004 & VBAP-UEPOS = BLANK &VBAP-AUART = Z000 & MVKE-MVGR2 = 001 -
    then SERVCODE = 201(201 is the Value to be passed to the target field to SERVCODE)
    u2022     IF VBAP-PSTYV = Z004 & VBAP-UEPOS = BLANK & VBAP-AUART = Z000 & MVKE-MVGR2 = 002 -
    then SERVCODE = 202(202 is the Value to be passed to the target field to SERVCODE)
    u2022     IF VBAP-PSTYV = Z004 & VBAP-UEPOS = BLANK & VBAP-AUART = Z001 & MVKE-MVGR2 = 001 -
    then SERVCODE = 301(301 is the Value to be passed to the target field to SERVCODE)
    u2022     IF VBAP-PSTYV = Z004 & VBAP-UEPOS =BLANK & VBAP-AUART = Z001 & MVKE-MVGR2 = 002----
    then SERVCODE = 302 (302 is the Value to be passed to the target fieldto SERVCODE)
    Thanks a lot in advance !!

    You may post it on a wrong forum.  Here is SAP Business One Core forum, a forum dedicate to SAP Business One - a solution to SME.  Please close your thread and try this forum to start:
    Process Integration (PI) & SOA Middleware
    Thanks,
    Gordon

  • Join 2 tables

    hi;
    i'm trying to join 2 tables (contact and personne) but it didnt succed
    this is my class contact
    package com.labosun.cj.ejb3.entity;
    import java.io.Serializable;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.JoinColumn;
    import javax.persistence.OneToOne;
    * Entity Bean Contact
    * @author Cyril
    @Entity // Annotation indiquant que la classe est un entity bean
    public class Contact implements Serializable{
    private int id;
    private String firstname;
    private String lastname;
    private String address;
    private int zipCode;
    private String city;
    private String phone;
    private String mobile;
    private Personne personne;
    @OneToOne
    @JoinColumn(referencedColumnName="FIRSTNAME")
    public Personne getPersonne() {
    return personne;
    public void setPersonne(Personne personne) {
    this.personne = personne;
    public Contact() {
    @Id // tag d���finissant la cl��� primaire
    @GeneratedValue(strategy=GenerationType.AUTO) // tag indiquant que la cl��� est auto g���n���r���e
    public int getId() {
    return id;
    public void setId(int id) {
    this.id = id;
    public String getAddress() {
    return address;
    public void setAddress(String address) {
    this.address = address;
    public String getCity() {
    return city;
    public void setCity(String city) {
    this.city = city;
    public String getFirstname() {
    return firstname;
    public void setFirstname(String firstname) {
    this.firstname = firstname;
    public String getLastname() {
    return lastname;
    public void setLastname(String lastname) {
    this.lastname = lastname;
    public String getMobile() {
    return mobile;
    public void setMobile(String mobile) {
    this.mobile = mobile;
    public String getPhone() {
    return phone;
    public void setPhone(String phone) {
    this.phone = phone;
    public int getZipCode() {
    return zipCode;
    public void setZipCode(int zipCode) {
    this.zipCode = zipCode;
    }and this is my class personne
    package com.labosun.cj.ejb3.entity;
    import java.io.Serializable;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.JoinColumn;
    import javax.persistence.OneToOne;
    * Entity Bean Contact
    * @author Cyril
    @Entity // Annotation indiquant que la classe est un entity bean
    public class Personne implements Serializable{
         private int id;
         private String firstname;
         private String lastname;
         private Contact contact;
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    public int getId() {
    return id;
    public void setId(int id) {
    this.id = id;
    @OneToOne(mappedBy="personne")
    public Contact getContact() {
         return contact;
         public void setContact(Contact contact) {
         this.contact = contact;
         public String getFirstname() {
              return firstname;
              public void setFirstname(String firstname) {
              this.firstname = firstname;
              public String getLastname() {
              return lastname;
              public void setLastname(String lastname) {
              this.lastname = lastname;
    }et le requete
    em.createQuery("SELECT contact.lastname FROM Contact AS contact JOIN contact.personne AS personne").getResultList().toString();

    when i tried LEFT JOIN i had result ( display all data in table contact) but when i tried RIGHT JOIN it just dislay null null null, i think that the problem in personne class bcuz its value was null
    this is my class personne
    package com.labosun.cj.ejb3.entity;
    import java.io.Serializable;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.JoinColumn;
    import javax.persistence.OneToOne;
    * Entity Bean Contact
    * @author Cyril
    @Entity // Annotation indiquant que la classe est un entity bean
    public class Personne implements Serializable{
    private int id;
    private String firstname;
    private String lastname;
    private Contact contact;
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    public int getId() {
    return id;
    public void setId(int id) {
    this.id = id;
    @OneToOne(mappedBy="personne")
    public Contact getContact() {
    return contact;
    public void setContact(Contact contact) {
    this.contact = contact;
    public String getFirstname() {
    return firstname;
    public void setFirstname(String firstname) {
    this.firstname = firstname;
    public String getLastname() {
    return lastname;
    public void setLastname(String lastname) {
    this.lastname = lastname;

  • Select single row in ALV grid

    ABAPer's ,
    Does anyone can guide me to select single row only in ALV grid , without OO.

    Hello,
    I did not get u.
    But check the below code it may help u.
    tables: mara.
    TYPE-POOLS: SLIS.
    data:repid like sy-repid.
    data: itb type mara occurs 0 with header line,
    IT_FIELDCAT TYPE STANDARD TABLE OF SLIS_FIELDCAT_ALV WITH HEADER LINE,
    IT_LAYOUT TYPE SLIS_LAYOUT_ALV,
    ITB1 TYPE MAKT OCCURS 0 WITH HEADER LINE.
    selection-screen begin of block b.
    parameters: p_matnr type matnr.
    selection-screen end of block b.
    select * from mara into table itb where matnr = p_matnr.
    SELECT * FROM MAKT INTO TABLE ITB1 WHERE MATNR = P_MATNR.
    repid = sy-repid.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
       I_CALLBACK_PROGRAM             = repid
      I_CALLBACK_PF_STATUS_SET       = ' '
       I_CALLBACK_USER_COMMAND        = 'HANDLE_USER_COMMAND'
       I_STRUCTURE_NAME               = 'MARA'
       IS_LAYOUT                      = IT_LAYOUT
       IT_FIELDCAT                    = IT_FIELDCAT[]
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
      IT_SORT                        =
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     =
      IT_EVENTS                      =
      IT_EVENT_EXIT                  =
      IS_PRINT                       =
      IS_REPREP_ID                   =
      I_SCREEN_START_COLUMN          = 0
      I_SCREEN_START_LINE            = 0
      I_SCREEN_END_COLUMN            = 0
      I_SCREEN_END_LINE              = 0
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
      TABLES
        t_outtab                       = itb
    EXCEPTIONS
      PROGRAM_ERROR                  = 1
      OTHERS                         = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    FORM HANDLE_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE
    SLIS_SELFIELD.
    CASE R_UCOMM.
    WHEN '&IC1'.
    CLEAR IT_FIELDCAT[].
    IF RS_SELFIELD-FIELDNAME = 'MATNR'.
    READ TABLE ITB1 INDEX RS_SELFIELD-TABINDEX.
    WRITE: / ITB1-MAKTX.
    ENDIF.
    ENDCASE.
    ENDFORM. "HANDLE_USER_COMMAND
    Regards

Maybe you are looking for