Join 2 tables which are not related with any primary-foriegn key constraint

Hello,
How to join 2 tables which are not related with any primary key foreign key constraint.
Ex.Consider Table A has 5 columns->A_ID,A_Name,A_Address,A_City,A_Pin(Total 10 rows)
Table B has 5 columns->B_ID,B_Name,B_Adress,B_City,B_City(Total 30 rows)
From both the table i want the data,which i need to use in curosr to display finally as "Address Label".
Both the table are entirely different,but there can be some names of Table A which may come in Table B also,if the name,address and city is also same.That means same person in both the table.
So finally i want total number of distinct records(distinct data of Table A which is not in B+all the data of table B) to come under Address Label.
How can i write the select query for this condition?
Thanks
Swapna

Hi, Swapna,
user11018268 wrote:
Hello,
How to join 2 tables which are not related with any primary key foreign key constraint.
Ex.Consider Table A has 5 columns->A_ID,A_Name,A_Address,A_City,A_Pin(Total 10 rows)
Table B has 5 columns->B_ID,B_Name,B_Adress,B_City,B_City(Total 30 rows)
Both the table are entirely different,but there can be some names of Table A which may come in Table B also,if the name,address and city is also same.That means same person in both the table.I think you want a UNION, not a join.
If you have 10 rows in table_a, and 30 rows in table_b, then
SELECT       A_ID,          A_Name,     A_Address,     A_City,     A_Pin
FROM      table_a
UNION
SELECT       B_ID,          B_Name,     B_Adress,     B_City,     B_City
FROM      table_b
ORDER BY            2,               4          
;will produce up to 40 rows; 40 if there are no duplicates. (UNION implies DISTINCT.)
The corresponding column types should be similar, if not exactly the same.
There's no problem if A_Name is VARCHAR2 (50) and B_Name is CHAR (30).
However, there will be a problem if A_ID is a NUMBER and B_ID is a TIMESTAMP.
You must have the same number of columns in all branches of the UNION.
If you want an ORDER BY clause, put it at the very end, after the last branch of the UNION.
You can use positional notation (where 2 means the 2nd column) like I did, or you can use names from the first prong of the UNION (such as A_Name).
From both the table i want the data,which i need to use in curosr to display finally as "Address Label".
So finally i want total number of distinct records(distinct data of Table A which is not in B+all the data of table B) to come under Address Label.I'm not sure what your mean about "Address Label".
Whenever you have a question, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables, and the exact results (formatted) that you want from that data.
You can concatenate all 5 columns into one VARCHAR2 column, if you want to.
You'll probably want to use RPAD (or simillar functions) to make the output line up nicely.
If any of the columns are not strings, use TO_CHAR to make string versions of them.
For example:
SELECT  TO_CHAR (A_ID, '9999999')
     || '   '          -- leave a little space between the left-justified a_id and the right-justified a_name
     || RPAD (A_Name, 25)
     || RPAD (A_Address, 50)
     ...Edited by: Frank Kulash on Nov 14, 2009 10:11 AM

Similar Messages

  • Identify tables which are not used in any access seq.

    Hi
    Need to identify those tables (A500 - A999) which are NOT used in any access sequence (table T682I).
    Not sure how to do this.
    Thanks for the help

    Hi Karen,
    if you don't want to use SE11 and see it on one glance, you could use the following coding:
    DATA: it_t682i TYPE TABLE OF t682i,
          wa_t682i TYPE t682i,
          it_missing TYPE TABLE OF t682i,
          wa_count TYPE kotabnr VALUE 499.
    SELECT * FROM t682i INTO TABLE it_t682i
                  WHERE kvewe = 'A'
                  AND  kotabnr BETWEEN 500 AND 999.
    DO.
      ADD 1 TO wa_count.
      READ TABLE it_t682i INTO wa_t682i
                 WITH KEY kotabnr = wa_count.
      IF sy-subrc <> 0.
        CLEAR wa_t682i.
        MOVE wa_count TO wa_t682i-kotabnr.
        APPEND wa_t682i TO it_missing.
      ENDIF.
      IF wa_count = 999.
        EXIT.
      ENDIF.
    ENDDO.
    BREAK 'your user'.
    The table it_missing is just a quicky solution, you could use a table with just one field or use write to print the result.
    Hope that helps!
    Regards
    Nicola

  • Delete records from tableA which are not in tableB

    Table A contains milions of records which is the best way to delete records from tableA which are not in tableB
    delete from tableA where empno not in (select empno from tableb)
    or
    delete from tableA where empno not exists (select empno from tableb
    where b.empno=a.empno)
    any help

    Hi
    If you can do this, do with this:
    create table tableC
    as select a.*
    from tableA a,
    (select empno from tableA
    minus
    select empno from tableB) b
    where a.empno = b.empno;
    drop table tableA;
    rename table tableC to tableA;
    Ott Karesz
    http://www.trendo-kft.hu

  • Some futures in bpel which are not possible with ESB and vice versa

    Can anyone please tell me some futures in bpel which are not possible with ESB and For some features available in ESB that are absence in BPEL?

    I think you've mistaken the meaning of both technologies. ESB actually works as a part of BPEL, for instance you can create partner link from any esb service.
    ESB service can only expose data or retrieve and process (transform) them from another service. BPEL is using services like ESB as a source and adds decision making functionality which is not present in ESB.

  • I have got a lot of apps, which are not installed on any of my iDevices anymore. is there a possibility to remove all those apps from iTunes without searching which ones are, and which ones aren't installed on one of my iDevices?

    I have got a lot of apps, which are not installed on any of my iDevices anymore. is there a possibility to remove all those apps from iTunes without searching which ones are, and which ones aren't installed on one of my iDevices?

    Assuming all the device(s) have been synced to this computer as its Home computer. The easiest way would be to delete all the apps from iTunes. After which connect your device(s) to the computer (iTunes) and transfer purchases from the device(s) by right click (control click) the device name in the left sidebar and the click transfer purchases. When done only the apps on your device(s) will be in you iTunes library.
    Hope that helps

  • We have the invoices in staging table which are not posting to EBIZ

    We have some invoices in RFM fm_ap_staging* tables from past month, which are not getting posted to EBIZ.
    The invoices are in FP status and the invoices should picked up and posted to EBIZ.
    We are not sure, why this was happening.
    But , when we have changed the sequence number of the invoices to the maximum sequence number and ran the batch , the invoices got picked up and posted to EBIZ.
    This doesn't make sense to me.
    Is it the correct functionality, or whatever is in the staging table evry thing should be picked up by the batch and post to EBIZ.
    Kindly verify.

    Hi Henry,
    From your description, I would like to verify the following things:
    1. If you can receive emails from ExQuilla account via OWA? If yes, the Exchange Server is ok.
    2. If other users can receive emails from ExQuilla account?
    3. When you use Outlook Anywhere, can you receive emails from Outlook client? If yes, there are some problems with the third-party software ExQuilla.
    If there are any problems with Exchange Server, please feel free to let me know.
    Best regards,
    Amy
    Amy Wang
    TechNet Community Support

  • HP Smart web printing is very useful web printing extension which is not compatible with any version of firefox till now but compatible with Internet Explorer any version. So Please do correction. Thanks

    [There is a link below from where software can be downloaded and after installing this you will see that it is not compatible with any version of Mozilla Firefox of any Window version (7, XP).]
    [http://ftp://ftp.hp.com/pub/softlib/software10/COL20395/dj-56929-3/HP_Smart_Web_Printing_v4.6.exe

    It is up to HP to make that program compatible with Firefox.
    That application last worked in Firefox 3.5, but HP was always very lax in updating it for a new version of Firefox. Usually they didn't bother to update it until like halfway through the "run" of a particular Firefox version. It worked for like 6 months and then a new version of Firefox was released, and it didn't work for like 6 months until HP got around to fixing it - then the cycle repeated.

  • Objects or Methods? Which are best related with performance?

    Good morning,
    I waked up this morning with a question in my mind. What is the best thing, to have objects inside another object or else to have methods?
    Okay the question may sound confusing, so I will simplify it with an example. Imagine having an object of type Client. This object needs to load all the client contact details from a file (simple text file).
    Now what would it be the best solution, to have the following code:
    public class Client{
       private Details details;
          public Client(){
             this.details = this.loadDetails();
          �
          public Details loadDetails(){
          �
    } OR
    public class Client{
       private Details details;
       private DetailsLoader loader;
       public Client(){
          this.loader = new DetailsLoader();
          this.details = loader.loadDetails();
    } It is very clear that in the first code segment I am using methods inside the same class to load the details of the client, while in the second code segment I am using another object to load these details.
    OOP wise the second method is better. But what If I have thousands or millions of clients registered in the system? That would mean that in memory, each one of these object (a 1000 for example) will have a DataLoader in memory as well (thus becoming 2000)! The more the numbers increase, the less the system will perform.
    I am asking this question because I want to develop something that still is strictly OOP, but that it is not so much of a heavy weight on a system.
    Any opinion on this is more then welcome :)
    Regards,
    Sim085
    Message was edited by:
    sim085 to correct code indentation.

    Thanks for the posts :)
    I am sorry my example was not clear enough. However all I wanted is to display the effects of having an instance of an object inside another object. I think the best solution would be to create an interface of type Client and then if the file needs to be loaded from an XML I would create a class XMLClient that implements Client (please not I am keeping the stupid example which most probably does not make sens).
    I did that example to show the difference that will happen in the JVM memory according to the different implementation.
    Imagine having object A that has a method load() to load the data from an XML file. Then in memory, when creating a new instance of type A, I will have the object A defined in the Heap, and the pointer to A in the stack.
    If instead I have an object A that has an object B with the method load(). Then if B is initialized from A, in memory I will have objects A and B in the Heap, and a pointer to both object in the Stack. If instrad object B is initalized from somewhere else and passed to A as a parameter, then I can have many instance of A while having one instance of B.
    I do not know if anyone understood the above. But what I am trying to say is that the different implementations, altough at the end of the day they will all result to the same ending, on the back end they are effecting the JVM in a different way!
    I know that the best solution is to feed B to A, so that I have one big object in memory loaded only once :)
    Was it "where am I?" ;-)No actually it was .. "shit I'm still here :D" :)
    regards,
    sim085

  • Adobe changed all my MOBI book files to Acrobat files which are not compatible with my Kindle

    How do we change my book attachments back to MOBI attachments?

    What is your operating system?
    How did "Adobe change all my MOBI book files to Acrobat files" - do they now have a .pdf extension?
    Or is perhaps your .mobi file association wrong?

  • Deleting Child records which are not associated to any parent

    Hi
    We have seen that in the application though the Activty records has been deleted the child records like sample dropped and the roduct details has remained in the system. This happened cos in R18 when contact was deleted activty got deleted but the Activity child records remained in the application.
    we found that child records are present by looking into record utilization.
    Wanted to know if there is any way to delete these child records from teh application cos we are unable to query for them from UI as well as via webservices.
    any pointers would be helpful.
    -MR

    There is not a reporting subject area or folder available on Books. The workaround we employed was to create a field on the entity that was assigned books and that field was checked when the books were assigned. We are using web services to assign books and the web services also updates the field "Books Assigned". This gives us a way of reporting on that field to see those records without book assigned.

  • SQL Query to find Receipt No.s which are not matched to AP Invoices

    Hi
    Please help me to frame a query to find list of Receipt No.s which are not matched with AP Invoices.
    Please refer to the below query .
    SELECT
    poh.segment1 "PO No.",
    aps.vendor_name "Supplier Name",
    pol.item_description "Item Description",
    rcvh.receipt_num "GRV No.s",
    rcvl.quantity_received "Quantity",
    pol.unit_price "Rate/Unit",
    rcvtl.tax_name||' - '||initcap(rcvtl.tax_type) "Tax",
    (rcvl.quantity_received * pol.unit_price) + nvl(rcvtl.tax_amount,0) "Amount"
    FROM
    po_headers_all poh,
    po_lines_all pol,
    po_distributions_all pod,
    ap_suppliers aps,
    rcv_shipment_headers rcvh,
    rcv_shipment_lines rcvl,
    rcv_transactions rcvt,
    jai_rcv_line_taxes rcvtl
    WHERE
    poh.po_header_id = pol.po_header_id
    AND poh.po_header_id = pod.po_header_id
    AND pol.po_line_id = pod.po_line_id
    AND aps.vendor_id = poh.vendor_id
    AND aps.vendor_id = rcvh.vendor_id
    AND rcvh.shipment_header_id = rcvl.shipment_header_id
    AND poh.po_header_id = rcvl.po_header_id
    AND pol.po_line_id = rcvl.po_line_id
    AND rcvh.shipment_header_id = rcvt.shipment_header_id
    AND rcvl.shipment_line_id = rcvt.shipment_line_id
    AND poh.po_header_id = rcvt.po_header_id
    AND pol.po_line_id = rcvt.po_line_id
    AND aps.vendor_id = rcvt.vendor_id
    AND rcvh.shipment_header_id = rcvtl.shipment_header_id
    AND rcvl.shipment_line_id = rcvtl.shipment_line_id
    AND rcvt.transaction_id = rcvtl.transaction_id
    AND aps.vendor_id = rcvtl.vendor_id
    AND rcvt.transaction_type = 'RECEIVE'
    AND poh.authorization_status = 'APPROVED'
    AND poh.segment1 = '210001079'
    I have'nt included the Invoice Tables in the above query.
    Please help me in that area.
    This is bit urgent.
    Please help me.
    Regards
    Nakul Venkatraman

    I am using ORACLE 11gR2 If you're licensed for Diangnostics pack then you might want to look at the AWR tables, e.g. DBA_HIST_SQLSTAT and cross-reference with DBA_HIST_SNAPSHOT.
    By this will i get the top 5 consumed queries of DEV user in the whole session or its just the top 5 queries at that particular time. The "executions" columns in this query, does it mean that the no. of. times the query has executed... This will get you a random 5 queries that were first parsed by DEV. Depending on your application code/structure, it may well be that all code (except for system-recursive sql) executed by DEV is parsed by DEV, and all code parsed by DEV is executed by DEV but this isn't true for all.
    In terms of top N queries, you need to ORDER BY and then restrict by ROWNUM at an outer level to the ROWNUM otherwise the ROWNUM filter is applied before the ORDER BY.
    i.e.
    SELECT *
    FROM
    (SELECT ...
    FROM ...
    WHERE
    ORDER BY...)
    WHERE ROWNUM <= ....
    The "executions" columns in this query, does it mean that the no. of. times the query has executedYes.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e25513/dynviews_3064.htm#REFRN30259
    Edited by: Dom Brooks on Oct 24, 2011 9:45 AM

  • Join two tables which stored in difference database

    Hi, i have a problem how to join two tables which are stored in difference databases. I'm using MS access and need to use Jsp to solve it. is anyone have idea to solve it. thxx

    Hi,
    I think you cannot join the tables which are in two diff databases. You have to connect to each database ,get the result and manipulate in your program. Use a bean.
    cheers,
    Narayana

  • Deletion of Request which are not updated to data target

    hi,
    I want to all PSA data whether it is updated or not In our project this is being done by Using a Process chain, But it is not deleting the request which are not updated to any data target or failed, I have selected both the check boxes
    Only successfully booked requests
    Only requests with errors, not updated in any data target
    but even after selecting this check box it is not deleting the failed request, can any one tell me why it is so.
    Any help in this would be highly appreciated.

    Try to do it without checking any of the checkboxes...
    Regards,
    Luis

  • Standard Manager executing other programs which are not INCLUDED .

    hello guys,
    We are having eBiz 11.5.9 environment and 9.2.0.6 Database on AIX 5.3 32-bit environment.
    I am new to this client's environment and found that, there are 3 include specialization rules defined for Standard Manager which does not include "Active Responsibilities" program but still this Standard Manager is executing "Active Responsibilities" without any issues.
    How is this possible ???
    Ideally, Standard Manager should only run those 3 included programs ONLY and for rest of the programs which are not assigned to any of the concurrent manager , we should get "INACTIVE/No Manager" message.
    My 2nd question is, when I am running this oracle seeded script $FND_TOP/sql/afrqscm.sql which shows the manager assigned to the perticular request id, it gives the below output,(Below is request id is for "Active Responsibilities")
    ===================================
    SQL> @afrqscm.sql
    Enter request ID : 22035368
    Request 22035368 can be run by the following concurrent managers:
    Running Manager
    20 STANDARD
    0 ALTS
    Below are the active concurrent manager log filenames:
    no rows selected
    ===================================
    In our environment , ALTS is DISABLED manager without having any specialization rules attached to it and its basically a "Backup standard manager".
    I am wondering, what setup is required to have backup concurrent manager like ALTS which will take care of requests in case standard manager goes down ?????
    Ebiz architecture is one Admin/conc/db Tier (Aix 32 bit) and 5 Web nodes ( RHEL Linux 32 bit).
    Thanks,
    Prasad
    Edited by: 881822 on Dec 7, 2011 3:00 AM

    Hi Hussein,
    Thnks for your reply,
    My second doubt is resolved as even though there are no specialization rules assigned to ALTS manager , that means it is exactly the same as that of Standard Manager and will execute all the programs. Below is statement from your mentioned pdf ,
    =========
    Specialize your manager to run only certain kinds of requests. Without specialization rules, a manager accepts requests to start any concurrent program.
    =========
    Regarding your first question, Yes , we do bounce managers once in a month , below is the status of those two conc programs which are INCLUDED in Standard Manager.
    SQL> select 'Concurrent program '||fcp.concurrent_program_name||' is ' ||decode(fcqc.include_flag,'I','included in ','E','excluded from ')||fcqv.user_concurrent_queue_name specialization_rule_details from fnd_concurrent_queues_vl fcqv,fnd_concurrent_queue_content fcqc,fnd_concurrent_programs fcp where fcqv.concurrent_queue_id=fcqc.concurrent_queue_id and fcqc.type_id=fcp.concurrent_program_id and fcp.concurrent_program_name='CPINR080C';
    SPECIALIZATION_RULE_DETAILS
    Concurrent program CPINR080C is included in Standard Manager
    Concurrent program CPINR080C is excluded from TESTPlus General
    SQL> select 'Concurrent program '||fcp.concurrent_program_name||' is ' ||decode(fcqc.include_flag,'I','included in ','E','excluded from ')||fcqv.user_concurrent_queue_name specialization_rule_details from fnd_concurrent_queues_vl fcqv,fnd_concurrent_queue_content fcqc,fnd_concurrent_programs fcp where fcqv.concurrent_queue_id=fcqc.concurrent_queue_id and fcqc.type_id=fcp.concurrent_program_id and fcp.concurrent_program_name='CPDOR270C';
    SPECIALIZATION_RULE_DETAILS
    Concurrent program CPDOR270C is excluded from TESTPlus General
    Concurrent program CPDOR270C is included in Standard Manager
    Thanks,
    Prasad

  • Table are not prefixed with Schema in  SQL request - Unable to get Data

    I began this new thread because I closed the [previous one|Unable to get data (DSN connection); a little bit early, I believed it was OK but no the problem still here.
    First my architecture :
    Oracle 9g
    +500 Reports made under CR developper 8.5 or 9.0
    Report opened in VB .net application, framework 2.0 using CR runtime 8.5 and 9.0
    We want to upgrade CR version to 2008, so modification of reports will be done with CR 2008 Developper, and we want to
    use only CR 2008 runtime.
    The problem :
    Everything works fine in CR Developer, but the same report with the same parameters failed when called inside .net.
    The error is "Unable to get data", the database connection is OK but the queries mades from inside the report are wrong :
    The tables/views in the from statement are not prefixed with the Schema, so Oracle don't find them.
    Example (SQL monitoring done with TOAD)
    Execution of postes.rpt report directly in CR :
    Timestamp: 10:30:03.881
    Successful logon attempt (session tag: 0x6464CB8)
    username: 'APPLI_HUET'; database: 'DEV'
    SELECT ...
    FROM  "COMMUN"."ETAB" "ETAB" INNER JOIN "GESTION_DES_TEMPS"."POSTES" "POSTES"
    ON "ETAB"."N_ETAB"="POSTES"."N_ETAB"
    WHERE  "POSTES"."N_ETAB"=2 ORDER BY "POSTES"."N_POSTE"
    Timestamp: 10:50:29.178
    Logoff (session tag: 0x6464CB8).
    Same report, same authentication but throught .net program :
    Timestamp: 11:01:24.569
    Successful logon attempt (session tag: 0xA93FC38)
    username: 'APPLI_HUET'; database: 'DEV'
    SELECT ...
    FROM   "ETAB" "ETAB" INNER JOIN "POSTES" "POSTES"
    ON "ETAB"."N_ETAB"="POSTES"."N_ETAB" WHERE  "POSTES"."N_ETAB"=2 ORDER
    BY "POSTES"."N_POSTE"
    Runtime error occurred: 942 (ORA-00942: Table ou vue inexistante)
    The .net code :
    Dim _report As New ReportDocument()
    _report.Load("report.rpt", OpenReportMethod.OpenReportByDefault)
    Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
    myConnectionInfo.ServerName = "DSN_file"
    myConnectionInfo.UserID = p_Userid
    myConnectionInfo.Password = p_Password
    ' to see code in this method se my original post
    SetDBLogonForReport(myConnectionInfo, _report)
    SetDBLogonForSubreports(myConnectionInfo, _report)
    Dim frmViewer As New CrystalReportViewer
    frmViewer.CrystalReportViewer1.ReportSource = _report
    frmViewer.Show()
    Any ideas ?

    Thanks for the and sorry but I don't understand.
    I've made a research of Location on this forum the more intersting thread I've found is rpt-files do not function anymore after deploying to a different database, but I still don't understand.
    I take a look at all code sample and I can't found anything.
    You say that .Location need to be set, indeed Location property of CrystalDecisions.CrystalReports.Engine.Table object only contains table name.
    I tried to overrides this value by the fully qualified table name (ie Schema.Table, for example GESTION_DES_TEMPS.POSTES), and it work  BUT it wouldn't be the solution, my code is designed to be generic, I can't have a database to know wich schema add before differents table name.
    Why when we execute the report directly in CR 2008 developper we don't have to redefine the table location ?
    Another test :
    I've made a new report directly in CR 2008 with a DSN, launch it in .net with the same DSN (server) : OK
    Then I launch it in .net with another DSN, it work also.
    Why report done with Crystal 8.5 or 9.0 have this problem ?
    I'me gonna be mad....
    Edited by: Yoann DAVID on Jan 8, 2010 3:32 PM

Maybe you are looking for

  • Should I Install Adobe AIR?

    Should I install Adobe AIR, I have a: iMac 24''  Processor  2.4 GHz Intel Core 2 Duo Memory  4 GB 667 MHz DDR2 SDRAM Graphics  ATI Radeon HD 2600 Pro 256 MB Software  Mac OS X Lion 10.7.1 (11B26) Is thier any reason not to run it? Is it safe? Thanks

  • New InfoObject is not available in the report in the QA system

    hai i transported one report to QA system . then i changed <b>one InfoObejct</b> in the InfoCube & report in the DEVB. Then i transported that report & infocube to the QA system. But when i try to open the report in the QA system then it says that ne

  • HELP with reloading applet AFTER it displays image

    Hi people I got a webpage that loads an applet which constantly needs to be refreshed in order for the applet to display a newer version of an image file (not very efficient I know). The image file is being constantly updated and so I need a way of r

  • I signed in for I tunes Switzerland. How can I get english spoken movies?

    I signed in for I tunes Switzerland, but I would like to download movies spoken in english. Is this possible? I tried to change  my page to USA  but I need then a new account. Do I have problems with two accounts when I  use my I Pad?

  • Google.fr Home Page - Link missing "Outils linguistiques"

    The link that stand next to the search box "Outils linguistiques" on the google home page (french) www.google.fr has disappeared... Annoying as it still visible in other navigators?