Three ways to join with key primary and composite foreign

Hi all

I have three tables

1 - test_data_items (test_data_item_id pk

test_data_item_name)

2 - data_items_in_tests (test_id, test_data_item_id) - both are a composite primary key.

3 - test_results (test_results_id, pk,

test_admin_id,

test_id, test_data_item_id)-both are a composite foreign key.

How to reach the three tables?

I want all the data, but I don't know how to write the join conditions when there are primary and foreign keys composite?

Thank you very much

Hello

Any condition (including a join condition) may be a compound of 2 or more of the simple conditions, combined using AND or OR.

Maybe that's what you want:

SELECT *- or the columns that you want to the list

Test_data_items I have

JOIN data_items_in_test d.test_data_item_id d = i.test_data_item_id

JOIN test_results r ON r.test_data_item_id = d.test_data_item_id

AND r.test_id = d.test_id

;

In this case, the join condition between tables d and r is a compound of 2 simple conditions, combined with the help of and.

The above query is just a guess.  There is not necessarily a unique way to join any 2 tables given.  Aptly named columns (and yours seem to have good names) and foreign key constraints can help you make better guesses about how to join the tables, but they are still all speculation.  They same 2 tables can be attached in different ways, depending on what is in the tables and what results you expect from them.  It's one of the reasons why, whenever you post a question, you must post a small example data (CREATE TABLE and INSERT statements), the results that you want from this data, as well as an explanation of how you get these results from these data.

See the FAQ forum: https://forums.oracle.com/message/9362002

Tags: Database

Similar Questions

  • Problem with the migration of key primary and foreign from SQL Server to Oracle

    Hi people, I use SQL Developer to migrate Oracle to a SQL database, and I'm stuck with a few questions:

    So far, the worst of them is the fact that I can not migrate the PKs and FKs. After having successfully captured the model DB in SQL Server and Oracle conversion, when the tool generates scripts, all ALTER TABLE queries that add pharmacokinetics and the FKs have their columns duplicate targets.

    for example: when I'm trying to migrate a simple table that contains an Id (PK) and the columns name, the tool generates the following scripts:


    PROMPT create Table TestTable...
    CREATE TABLE TestTable)
    ID NUMBER (10,0) NOT NULL,
    Name VARCHAR2 NOT NULL
    );

    The PROMPT create constraint primary key on the table TestTable PK_TestTable...
    ALTER TABLE TestTable
    ADD CONSTRAINT PK_TestTable PRIMARY KEY
    (
    ID,
    ID
    )
    ENABLE


    Regarding the FKs, the tool duplicates the columns thus:

    ALTER TABLE SomeTable
    ADD CONSTRAINT FK_SomeTable_SomeTable2 FOREIGN KEY
    (
    SomeTable2Id,
    SomeTable2Id
    )
    REFERENCES SomeTable2
    (
    ID,
    ID
    )
    ENABLE
    ;

    Does anyone have an idea on how to solve these problems? I would be very grateful for answers!

    Hi Fernando,

    I was unable to reproduce this problem. My primary / foreign keys when defined using unique columns.

    The PROMPT create constraint primary key on the suppliers table PK_Suppliers...
    ALTER TABLE suppliers
    ADD CONSTRAINT PK_Suppliers PRIMARY KEY
    (
    Vendor No.
    )
    ENABLE
    ;

    I tried a few things like
    capturing twice and rename the two models of the same
    Rename the converted templates
    but without success.
    I think that this problem occurs is in the capture phase or convert.

    (1) you perform the capture online or offline?
    (2) can provide you a DDL together for one of these tables and the indexes to see if I can reproduce?
    (3) made of capture or convert fail or be again at any stage?

    I all else fails I would attempt a capture and convert again using a new repository (create a new schema in Oracle and associate him the migration repository).

    Kind regards
    Dermot
    SQL development team

    Published by: Dermot ONeill on October 22, 2009 12:18

  • Re: Equium P300-19O - problem with keys mute and lighting

    Until that point, I had no complaints with my laptop having bought two years ago.

    Above the keyboard, next to the power button is that media touch allowing lighting to parts of the laptop and play/pause button etc for playback of the media.

    Two days ago, I turned on my laptop and I noticed these buttons did not work, and even when the laptop was turned off and the power cable not inserted the lights stayed on.

    I don't know what can anyone offer any suggestions or help?

    Hello

    You must reinstall the VAP (value added package).
    The PPV contains the software and tools that control the multimedia keys

    You will find the PPV on the European driver Toshiba page.

    Welcome them

  • How to join two tables to retrieve the data from the columns in table two. Tables have primary and foreign key relationships

    Hello

    I want to join the two tables to retrieve the data from the columns of the two table passing parameters to the join query. Tables have primary and foreign key relationships

    Details of the table

    Alert-1 - AlertCode (FK), AlerID (PK)

    2 AlertCode-AlertDefinition-(PK)

    Help, please


    ----------

    Hi Vincent,.

    I think that you have not worked on adf 12.1.3.  In adf 12.1.3 you don't have to explicitly create the association. When you create the EO to your table, Association xxxxFkAssoc, will be created by ADF12.1.3 for you automatically. Please try this and do not answer anything... You can also follow the links below. I solved the problem by using the following link

    Oracle ADF Guide step by step - Oracle ADF tutorial: creating a relationship of the master / detail using Oracle ADF

    ---

  • ORA-01445: cannot select ROWID, or sample, a view of join without key - preserved table form w/report and LOV

    I create a page "Form on a Table with Report" (APEX 5). Table I has 3 columns: cat_key, item_value, item_description. The cat_key is a foreign key in a table with columns cat_key, cat_value. I created the report and everything works fine.  The page of the report shows my domain cat_key in number, so I want it instead to display the cat_value. I change the field cat_key to a text based on LOV, select my LOV and now when I view the page of report I get the "'ORA-01445: cannot select ROWID from where sample, a join without key preserved table view ' error." The report uses the ROWID as a link to the edit page field.

    If I use the same tables and even shared LOV in a report page interactive, it works fine.

    What I am doing wrong?

    This is a limitation of the IR Apex will rewrite your query to a query that includes the lookup table and the columns. So now you have actually created a query on an inline view, which causes the error. You can see the query apex created when running in debug mode. APEX will join the table of choice with your primary table. For example from one of my IR:

    Select 'ID '...

    "MSL". "" HIS_COUNTRIES "=> my primary table

    ) ) b,

    (select rv_meaning d, rv_low_value r

    of msl_ref_codes_table

    where rv_domain = "JOHN".

    ) L1 = > query My LOV Lookup

    ...

    So, if possible, base your reports and forms on the real primary key, no rowid.

    You can also write the IR query with the search yourself:

    Select T1.rowid...

    of primary_table T1

    look_table L1

    ...

  • Problems with the primary key of the query string

    Moving from asp to php, to work with David Power's book: The Essential Guide to Dreamweaver CS4 with CSS, AJAX, and PHP.  Recycling of my brain, so starting from scratch in the learning process.

    Everything was going perfectly until I tried to add the primary key of a record in a query string.  I compared my code with the example code for the book, and everything matches.  When previewing the page in my browser and hover over the link which must pass the main code on the next page, the query string does not appear correctly.  It shows user_id = but no figure shows, as it is supposed to.  www.webpage.com/update_user.php?user_id=

    Here is my code: (Please note, <>have been removed, as I was unable to find a way view the code in the correct way here (copy/paste was doesn't work do not, nor insert syntax))

    ? PHP {?}

    ? PHP echo $row_listUser ['family_name'];? PHP echo $row_listUser ["FirstName"];?

    ? PHP echo $row_listUser ['username'];?       ? PHP echo $row_listUser ["admin_priv"];?

    a href = "update_user.php? user_id =? php echo $row_listUser ['user_id'];?" "Edit / has

    a href = "delete_user.php? user_id =? php echo $row_listUser ['user_id'];?" ' Delete / has

    ? PHP} while ($row_listUser = mysql_fetch_assoc ($listUser));?

    Any ideas that could help me understand why this part does not in particular would be greatly appreciated.  Writing to the database worked perfectly, I see that there are numbers in the database as user_id, and it is defined as my primary key in the configuration database.  Such a simple process that is causing me headaches!

    Thank you

    You have the code to request a copy in your folder:

    $query_listUser = 'SELECT user_id, username, first_name, family_name, admin_priv from users ORDER BY family_name ASC';

    $listUser = mysql_query ($query_listUser, $connSCFDIR) or die (mysql_error ());

    $row_listUser = mysql_fetch_assoc ($listUser);

    $totalRows_listUser = mysql_num_rows ($listUser);

    $query_listUser = 'SELECT username, first_name, family_name, admin_priv from users ORDER BY family_name ASC';

    $listUser = mysql_query ($query_listUser, $connSCFDIR) or die (mysql_error ());

    $row_listUser = mysql_fetch_assoc ($listUser);

    The $listUser table will contain the results of the second query, which does not include the field user_id. delete the redundant code.

  • I bought Lenovo G550, 6 months before and now I m is problem with key product of Windows because of the striped top, so please tell me how it would be possible to get this product key

    I bought Lenovo G550, 6 months before and now I got problems with my PC and have problem with the Windows product key due to scratch on it, so please tell me how it would be possible to get this product key.

    Behind my laptop, here is a sticker mentioned
    Proof of license
    Certificate of authenticity
    Microsoft
    Microsoft Corporation @2005
    X 15-53803
    and on the bar code is mentioned after the number.
    00.94 - 893-397-158
    Product key. M... 62-8GX88-69-... - f7b

    Hello BHASKARPIYA,

    Product Key Finder programs, if someone advises to use, is found only on your operating system preinstalled a Levono multiple factory facilities and will be of no use in these circumstances.

    You will need to contact Lenovo and request their assistance.

    Or a way around this is to buy a Lenovo recovery DVD to reinstall the operating system or use the built-in recovery Partition containing an image of your OS and reinstall Windows like that.

    No method requires a product key to be entered by you.

  • ButtonField who works for normal click and also occurs a different action with a key down and click on

    I have a bunch of buttons on my main screen. They currently do something when you click on it. I want to make them do something different when ALT-clicked. I built them as:

    ButtonField mycoolbuttonname = new ButtonField("Awesome",ButtonField.CONSUME_CLICK);
    

    Then I assigns each a ChangeListener which then redirects this specific to a specific code listener.

    How can I run an ALT + click on a different code of FieldChangeListener?

    I think somehow with: KeyDown API

    I have several buttons on a screen. All work now with: 1. click on Trackpad 2. Touch-click 3. Enter-click

    I want each button to be able to do two things:

    1. a thing with an ALT-activate(by any of the three ways as seen above)

    2. a normal else activate (by one of three ways as seen above)

    Dominant Navigation click would not however to ALT-Enter and Alt-Touch(The way I want it is that these two do #1 from above too). Correct or not?

    In the simplest possible terms:

    Each button will make a specific thing turn on and another thing different specific on ALT-putting into service.

    Right now, they work absolutely fine to do a thing. But I'll try to find a way to make them also to do something else on ALT-putting into service.

    I think if I can somehow make a way to get the true/false if ALT is pressed during a change of field and then do an if/then based on this information in each fieldChanged method so I should be good.

    Update: well, I got the errors go away with your code above. At least press Alt-Trackpad works. I'm going with it. Thank you!

  • Another user changed the row with a primary key oracle.jbo.Key]

    I see many discussions about this error, but still cannot understand the difficulty that I need in my scenario.

    I am an Oracle Developer and completely new to ADF, please bear with me.

    I use JDeveloper 11.1.1.9.0

    My scenario:

    Creates an object editable view (UVO) with sub selects in the query, which is from several db tables.

    Creating a table using the UVO

    When I try to update a field in the table, and then click the validate, I get the error message:

    Another user changed the row with a primary key oracle.jbo.Key]

    Can someone explain in what scenarios I see this error and how do I solve this problem?

    Try the viewObject execution after validation and reQueryOnCommit set to true

    For details see - binary: a reason more for "Houston-25014: another user has modified the line containing oracle.jbo.Key primary key '

    Ashish

  • I want to activate Acrobat Pro 9 serial key and get message that are 2 active activations. We're old computer with problematic material and other is the same pc that I didn't turn off the license and reformatted. What should do?

    I want to activate Acrobat Pro 9 serial key and get message that are 2 active activations. We're old computer with problematic material and other is the same pc that I didn't turn off the license and reformatted. What should do?

    I didn't know, I had to disable before turning back, but now I don't have this option. Is there a way to disable these two licenses and activate again the good?

    Hi vasilisp36877173 ,

    Please see these items:- Learn how to enable or disable Adobe applications

    Solve the problems of activation and deactivation of Adobe and error messages

    Let me know how it goes.

    Kind regards

    Christian

  • Premiere Pro CC 2015 - application of clip and rendering (three-way) color correction

    -Every tutorial I see said: 'Drag the clip on the timeline and drag the effect to the element' - and in fact, when I do that, the clip changes color, indicating that the effect has been applied, I guess. But then the color correction controls do not seem to enable editing. I guess I sort of myself painted in a corner UI by freezing the arrangement of the components (or something - have no idea and don't hit FWIW, no button or options which do not seem to have the effect of blocking the UI) so that the color correction controls are hidden. I know it sounds like a silly problem, but I would greatly appreciate a clue, if you have any suggestions to offer.

    If you have your clip on the timeline and apply the color corrector effect three way, once you have dragged the effect to the clip with the clip still highlighted (selected) on the timeline, click the effect options panel.

    MtD

  • Engineering problems the surrogate with Unique key primary key

    SDDM 3.3.0.747 with 2 problems (at least so far).  I hope that the problem comes from this recruit SDDM and I forgot a setting. PROBLEM 1 I don't want to start a religious debate on substitution vs natural keys but I'm having a problem correctly both the logic model of engineering.  I'm a rookie when it comes to SDDM but have many years of experience with the Designer. By default, only I wish I had a natural UID (UK) and a surrogate mother based on a primary key UID (PK) which is used for foreign keys.  The problem I have with engineering is I can successfully engineer the substitute PK, engineer of the FK with the PK, but cannot get the unique key to contain surrogate keys in the child table.  If I check the identification property in relationships, the PK columns and the UK are included in the child PK and the United Kingdom contains no columns. The installation program, I've defined two reference entities, PROBABILITY and GRAVITY with unique keys natural defined.  I also have a child entity RISK_ASSESMENT with links to entities of the PROBABILITY and SEVERITY and both have the "use surrogate keys:": check box selected.  The unique key of the entity RISK_ASSESMENT includes links to PROBILITY and GRAVITY.  None of the entities have a PK or replacement of the defined keys and they all have the checkbox "Create a surrogate key" checked.  In addition the following preferences are defined: Data Modeling/model/logic NO checked - use and the first Unique key as primary key value NOT checked - name - Keep under the name of the from attribute Checked - entity carrier to create controlled key - use surrogate PROBLEM 2 key relationship when the foreign key columns are engineered I want names have a prefix 'FK_"but they don't.  Models are defined as follows: Data Modeler/assignment of Standard/Templates Foreign Key name: FK_ {children} {parent} foreign key column: engineer FK_ {Ref column} relational model/General checked Options - translation name Marcus Bacon apply

    Once more, I designed without removing anything and still no FK to the United Kingdom of the child.

    There is a synchronization problem in DM 4.0 EA1. This will be fixed for the production version.

    Philippe

  • I have the model of macbook air 2016 with i5 Professor and 8 GB ram... since it's the fastest ssd, but I have not seen all speeds up to now, I want to say is bcz I need to have usb 3.0 USB key or hard drive to see the speed of the ssd to usb 2.0 will work

    I have the model of macbook air 2016 with i5 Professor and 8 GB ram... since it's the fastest ssd, but I have not seen all speeds up to now, I want to say is bcz I need to have usb 3.0 USB key or hard drive to see the speed of the ssd to usb 2.0 will work

    What do you mean, your message is not clear.

  • I have copy of old tbird and seamonkey e-mail files with the files and emails for each. I need to add to new tbird install. can not find a way to do it. Help

    I have copy of old tbird and seamonkey e-mail files with the files and emails for each. I need to add to new tbird install. can not find a way to do it. HELP PLEASE. previous e-mail files are under mail then mail.earthlink* .net and each of the five mail .net is an email address I have. I can't find a way to identify each file by email to the specific email address (IE mail.my E-mail name.net) so I can copy the files and emails from the past to the email addresses now under tbird. previous installed e-mail identities may not be the current configuration of e-mail files in tbird. I think that I must be sure that mail.name.net matches the previous mail.name.net to be able to copy and paste the old to the new. is there a way to find the file name correct the old email and correspond to the new? all my emails very important information are mostly in the old mail electronic id and must be available in the identification of email again (but same) how can I do this?

    http://KB.mozillazine.org/Importing_folders

    Use this module.

    https://addons.Mozilla.org/en-us/Thunderbird/addon/ImportExportTools/

  • HP 15 - ac043tu: need help with the key feature and WiFi Drivers

    Hi team,

    I try to activate the key feature and WiFi in my new HP 15 - ac043tu laptop.

    I use Windows 7 Ultimate 32 operating system.

    I installed all the drivers available on the site Web of HP (http://support.hp.com/us-en/drivers/selfservice/HP-15-ac000-Notebook-PC-series/7771404/model/8326116... for my product.

    To activate the function key, I installed driver: HP System Event Utility - sp71716, but it doesn't seem to work.

    In Device Manager, network controller shows exclamation as shown below. I tried to install Broadcom and Realtek WLAN drivers, tried to turn on/off, uninstalled/reinstalled drivers referring to other positions, but that did not work.

    I also tried to install HP SoftPaq Download Manager, but it did not help. Tool does not show my product described.

    I went through a similar question posted by other members, but failed to get the solution. This question gave me hard times.

    Appreciate your help in this regard.

    Thank you

    Kishan

    Hello:

    You need these drivers wireless and bluetooth driver 64-bit file should have the 32-bit drivers too.

    Network controller (wireless card):

    FTP://FTP.HP.com/pub/SoftPaq/sp71501-72000/sp71528 .exe

    Bluetooth:

    This package contains the Broadcom bluetooth driver and software for the laptop models running a supported operating system. Broadcom Bluetooth 4.0 driver is required to activate the bluetooth 4.0 Broadcom devices and is compatible with Broadcom bluetooth 3.0 and earlier versions.

    File name: sp71440.exe

    Unfortunately, I can't help you with the next question.  The system of the event utility would be the only software I can think that would have worked.

    You can try the software HP Quick Launch, but I doubt it will work.

    http://h20565.www2.HP.com/hpsc/SWD/public/detail?swItemId=ob_112835_1

Maybe you are looking for

  • 6s + and Itunes software

    I've recently upgraded to a 6 + 6 s + and want to sync with my Mac.  When I plug my new phone and open Itunes, it reads that I can't use my phone because it doesn't have the latest version of Itunes.  Have updated my Mac, I don't see software updates

  • plugin - container.exe * 32 is a drain on resources

    When I run Firefox I find that the "plugin - container.exe * 32" is a drain on the resources of my computer. Is there a way to disable this? I understand that its purpose is to help if Firefox crashes, but because my Firefox crashes almost never I fe

  • synchronization problem

    I have a playlist customized with 77 songs about it... but when I sync with ipod classic there are only 76 songs.  missing roy orbison pretty woman. not much I know but what I'm doing wrong.  I resynced several times and it still does not appear on m

  • NOT AUTHENTIC WINDOWS PROGRAM

    I recently moved fron to the United States, to the Mexico, after my computer connected to the internet now I get a message the windows xp Pro copy on my computer is not authentic to used in the field I'm located... never had a problem bofore, any ide

  • I doubleclick on an icon and open with rises

    Hello Im having a problem with my Vista OS Im running Vista x 64 home premium and now when I double click on a folder icon 'Open with' appears. It's petrol with all the icons and the only way to open an icon must run as an administrator. Similarly, I