Question on join

Hello world

I have a question about the join.


I have 3 tables... USER FROM POINT 3 OF the AGENDA) 1 2))

Suppose if I want to know the total QUANTITY of ITEM for a userid of the user = 10, I need to join all the 3 tables.

I have no information, 3 tables do not join to the rest of the users.

I tried several ways... like nested box instructions... .but no luck.
select case when u.userid=10 then i. itemquntity
else null end as ITEMQUANTITY 
from user u
join order o
on o.id=u.orderid -- and u.userid=10
join item i
on i.id=o.itemid

NOTE: My query is in view that can be called by all the other users. Only USERID=10 needs ITEMQUANTITY rest of the users i want to avoid that joins (NULL will be fine)
How to write a simple select query?

version 11.1.0.7

any ideas...

Thank you
Mike

Hi, Mike,.

Mike wrote:
Hello world

I have a question about the join.

I have 3 tables... USER FROM POINT 3 OF the AGENDA) 1 2))

The USER is not a name very good table. It is the name of a built-in function (in fact, you can use it in this problem) and will be confusing. Why not call the table USER_TABLE or MY_USERS?

... How to write a simple select query?

You want a single query? Two separate petitions be much simpler and more effective?

If you want everyone to say the same thing (for example ('SELECT...) X"), but they have x means a different view for the user = 10 ID it does for everyone, then create a special view just for userid = 10, either in the scheme of this user, or create a synonym of have in this schema of the user by referring to the special view.

If you create a query (or view: I'll just say view later), then you will have to join three tables and hide some of the information form everyone except userid = 10. Maybe it's not difficult. You might be able to outer join the other tables to user_table and 'AND u.userid = 10' part of the join condition. All the columns of these tables will be NULL for all users except userid = 10.
It will be ineffective. You will have the expense of do outer joins whenever someone uses the view, even if a single user will see ever all data from joined tables.

I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post two sets the outcomes from these data:
(1) the userid = 10 results should see
(2) the results, everyone should see

Tags: Database

Similar Questions

  • two questions. question 1: join the clouds will give me access to QuarkXpress.

    two questions. question 1: join the clouds will give me access to QuarkXpress.

    QuarkXpress is not an Adobe product. The QuarkXpress product page is here http://www.quark.com/Products/QuarkXPress/.

    To see which products are included with Adobe Creative Software cloud go to this page https://creative.adobe.com/apps. There are learn more links for each of the products and services included.

  • questions about join quter

    Hi all
    I am now learning on the outer join.
    so far, I've learned the syntax of the "right outer join" / «left outer join»»»
    now, I try to understand the other syntax with the (+) sign sign.which I tried to find explanations to this sign
    without success

    lets talk about the left outer join:
    select a.id,b.name from 
    employees a left outer join names b 
    on a.id=b.id 
    issues related to the:
    1. in the syntax with the sign of the operator (+), I need to like this left join BOF:
    select a.id,b.name from 
    employees a, names b 
    where a.id = b.id (+)
    My question is why?
    What this sign means? If the left join supposed to return all lines
    the left table independently to corresponding records in the right table isn't this supposed to be
    where a.id(+) = b.id
    Please explain?
    2. If we continue with the outer join operator (+),
    How am I supposed to do no outer join? which means: can I leave the
    side of the location of the table the same and just change the location of the operator (+) side? as it is, we mean:
    If it is not join:
    select a.id,b.name from 
    employees a, names b 
    where a.id = b.id (+)
    
    does the right join  will look like this :
    select a.id,b.name frin 
    names b , employess a 
    where b.id = a.id(+) 
    
    or  can i  do also like this ? meaning just moving the operator (+) sign ? 
    select a.id,b.name from 
    employees a, names b 
    where a.id (+) = b.id 
    is the last syntax o.k and legal ?
    3 are the columns of the tables assume appear in the query and in where clause in the same order?
    lets say:
    select  *a*.id, *b*.name from 
    employees *a*, names *b* 
    where *a*.id = *b*.id(+) 
    or is it o.k to do like this too : 
    select *b*.name,*a*.id from //the column name appers on the left while the table employess b appear on the right 
    employees *a*, names *b* 
    where *a*.id = *b*.id(+) // in the condition relation are they suppose to appear in the same side as their tables ? 
    4. What is the significance of this kind of syntax:
    select b.name,a.id from 
    employees a, names b 
    where a.id = b.id(+) and 
    a.street = b.street (+) 
    5. What is the meaning of the sign < or > in the outer join:
    example:
    select .name,a.id from 
    employees a, names b 
    where a.id > b.id(+) 
    6.
    y at - it or the outer join condition too?
    7. in what way is best to write the outer join?
    with the sign of the operator (+) or with the "... outer join" sentence?
    Thanks in advance
    Naama

    Under the direction of: naama on December 23, 2010 05:56

    Under the direction of: naama on December 23, 2010 06:11

    Hi, Naama,

    Sorry, I don't understand the question.

    Naama wrote:
    Hi Frank
    I have drawn on your explanation, I got a few concludes we will see if I can:
    I can say that if I have an outer join complete with the State "and" which refers to one of the table, as in this command:

    
    select t0.comp as comp_T0 ,
    t0.type_i           AS type_i_t0     ,          -- For debugging only
    t2.comp as comp_T2,
    t2.type_i           AS type_i_t2     ,          -- For debugging only
    t0.amt type_0,
    t2.amt type_2
    from table_summary t0
    *full join* table_summary t2
    on t0.comp= t2.comp --linked column
    and t2.type_i = 2 --addition to the condition that relates to just one of the table (the "extra" condition) 
    

    Please makes it difficult for people to help you. The format of your code. In particular, he dash so that it is easy to find the main proposals, including FROM and WHERE.

    so I can say that the table with the 'extra' condition becomes the table of conduct (according to my specific example: T2 is the driving table).

    Do you mean that t2 is the 'engine', but is not the case of the t0?
    I don't understand what you mean by "table of conduct." Earlier you seemed to use 'conduct table' to refer to the table of in

    FROM            d
    LEFT OUTER JOIN       t     ON ...
    

    or

    FROM            t
    RIGHT OUTER JOIN  d     ON ...
    

    in other words, table in these asymmetrical relations whose lines will appear in the result set, even if that line has no match in t.
    FULL OUTER JOINs are symmetric; two tables are used the same way. In a FULL OUTER JOIN, rows in each table must be included in the game even if they have no match in the other table. If one of the tables is 'flying', how can you say that the other table is not "led" as well?

    and the query is corrlated as if I was doing:

    select t0.comp as comp_T0 ,
    t0.type_i           AS type_i_t0     ,          -- For debugging only
    t2.comp as comp_T2,
    t2.type_i           AS type_i_t2     ,          -- For debugging only
    t0.amt type_0,
    t2.amt type_2
    from table_summary t0
    *right join* table_summary t2
    on t0.comp= t2.comp --linked column
    and t2.type_i = 2 --addition to the condition that relates to just one of the table ,
    

    Instead,.
    because through the example of all, I saw that there were none concern the t0 is an outer join means that the conduct at the table, only in the table back.
    Am I wrong?

    Ask yourself if the FULL OUTER JOIN you posted at the beginning of your last message is equivalent to the RIGHT OUTER JOIN you posted more far in this message?
    No, they are not equivalent. With the sample data that John Spencer posted on 30 December, the two queries above happens to get the same results, but, generally, they will not get the same results. For example, if you add this line in the sample data:

    SELECT  9 AS comp,  0 AS type_i,  860 AS amt     FROM dual     UNION ALL
    

    then the set of results of the FULL OUTER JOIN will include these two production lines:

    `  COMP_T0  TYPE_I_T0    COMP_T2  TYPE_I_T2     TYPE_0     TYPE_2
    ---------- ---------- ---------- ---------- ---------- ----------
             9          0                              860
                                   9          0                   860
    

    but the RIGHT OUTER JOIN that you posted will get one of these lines:

    `  COMP_T0  TYPE_I_T0    COMP_T2  TYPE_I_T2     TYPE_0     TYPE_2
    ---------- ---------- ---------- ---------- ---------- ----------
                                   9          0                   860
    
  • Question about joining and separating some simple traces

    Hello, I have a vector image of a logo and here to recreate the 'e' appearing in the image here without the missing gap, where a picture point used to be.  I'm fairly inexperienced in Illustrator and seeks advice on the best way to associate this zone in the most simple way and smoother appearance possible.

    Further, since I will use this to get an effect of masking in Flash, I would like to know how I can separate the areas of intersection on the left side of the "e", so it appears as a worm - like single line/swoosh.

    Thanks for any advice.

    -Courtney

    Picture 1.png

    Courtney,

    Assuming that there is no question pending of the copyright, you can:

    (1) cut each of the anchors away with the scissors tool.

    (2) join each part of the path by dragging on the Anchor Points to attach with the direct Selection tool and CTRL / Cmd + J, now you straght join parts with corner at both ends Points;

    (3) ClickDrag every Coner Point with the tool convert point of anchor (the pen tool launcher) to get the right curves, it may take a few tries until you get them right.

    You can cut the tail where it joins the back of the e with the scissors tool. (you can repeat 2) and 3) If you want to join the pieces with curves.

    Always work on a copy when you destroy work.

  • question about join internal

    I have the following table.
    create table table_g 
    (
       zone_id varchar2(30),
       zone_quantity number(5));
    with the following insert statement

    insert into table_g
      (zone_id, zone_quantity)
    values
      ('AA',5);
    insert into table_g
      (zone_id, zone_quantity)
    values
      ('BB', 6);
    insert into table_g
      (zone_id, zone_quantity)
    values
      ('CC', 7);
    insert into table_g
      (zone_id, zone_quantity)
    values
      ('   ', 5);
    insert into table_g
      (zone_id, zone_quantity)
    values
      (v_zone_id, v_zone_quantity);
    I also have another table called table_gforce
     create table table_gforce 
    (
       gforce_zone_id varchar2(30),
       describe varchar2(30),
       user_name varchar2(30)); 
    who has filled with the following insert statement
    insert into table_gforce
      (gforce_zone_id, describe, user_name)
    values
      ('AA', 'mid-range', 'john');
       
    insert into table_gforce
      (gforce_zone_id, describe, user_name)
    values
      ('BB', 'mid-long', 'kris');
    
    insert into table_gforce
      (gforce_zone_id, describe, user_name)
    values
      ('CC', 'mid-short', 'Henry');
      
    insert into table_gforce
      (gforce_zone_id, describe, user_name)
    values
      ('   ', 'mid-=field', 'zack');
      
    insert into table_gforce
      (gforce_zone_id, describe, user_name)
    values
      ('DD', 'mid-period', 'melissa');
       
    insert into table_gforce
      (gforce_zone_id, describe, user_name)
    values
      ('VV', 'mid-distance', 'frank');
    
    insert into table_gforce
      (gforce_zone_id, describe, user_name)
    values
      ('AA', 'mid-location', 'graham');
      
    insert into table_gforce
      (gforce_zone_id, describe, user_name)
    values
      ('AA', 'mid-vision', 'ethnic');
      
      insert into table_gforce
      (gforce_zone_id, describe, user_name)
    values
      ('AA', 'mid-class', 'veronica');
      
       insert into table_gforce
      (gforce_zone_id, describe, user_name)
    values
      ('AA', 'mid-power', 'placement');
      
    insert into table_gforce
      (gforce_zone_id, describe, user_name)
    values
      ('AA', 'mid-keeper', 'rant');
    now, I'm doing an inner join by using the following statement
    select p.zone_quantity, y.describe from table_g p inner join table_gforce y
    on p.zone_id = y.gforce_zone_id;
    However, even if I have the following question... I need to change my inner join so that she joined on AA with AA, BB with BB, CC with CC and ' ' with everything else. How to do that. Thank you.

    Published by: user13328581 on August 30, 2010 09:24

    Hello

    Whenever you have a question convcerning an error, display the full error message, including the line number and the complete code I got the error.
    Whenever you have any questions, tell what version of Oracle you are using. The statement I posted works in Oracle 10.1.0.2.0.
    If you are using a very old version of Oracle, you may need to re - write the WITH clause as a point of view online. In other words, instead of

    WITH  got_r_num   AS
    (
        ...
    )
    SELECT  ...
    FROM    got_r_num
    WHERE   ...
    

    say:

    SELECT  ...
    FROM    (
                ... -- what had been in the WITH clause goes here
            )
    WHERE   ...
    
  • Question about joins.

    Dear forummembers,

    My apoligies for registration to these forums with a question already but I've been stuck with this problem since last year when I started with SQL.

    Initially a small introduction! My name is Bryan Brandt of Belgium and I am a student in the PHL College/University of Hasselt. I'm in my second year of applied computer science.
    Since the first year I seem to have a lot of trouble with joins. Not so much with small joints like (join of a table used with for example a department table). However when it comes to larger queries and we need to have 4 / 5 tables to join, it is quite another story.

    Is it possible to learn it in a simple way? I searched around on google without much luck, he helped me a lot.

    In any case, I want to thank you for your time and hope to hear from you.

    Have a wonderful day!

    Bryan

    Ok. Let's start with this:

    m3.chef = m3.mnr;
    

    Is this a typo in (m3 here twice)?
    Or did you really only query lines where the value of column HEAD is equal to the value of column MNR? That is looking for employees who "manage set apart them by one.

    I understand that you are able to query employees and include their right to Department?
    How you could build this query is as follows.

    Let's start with the employees:

    select e.naam
    from employee e;
    

    Now add the naam Department, by walking from the afd. FK in the employee for the department table table.
    We add FROM the Department and add the join condition to the place WHERE.

    SELECT e.naam, d.naam as afdelingsnaam
    FROM
       employee e,
       department d
    WHERE
       e.afd = d.anr;
    

    And finally, add the naam of the head, walking head-FK in the employee table to (another instance of) the employee table. We add a second table used to FROM and add a join condition to the place WHERE.

    SELECT e.naam, d.naam as afdelingsnaam, e2.naam chefnaam
    FROM
       employee e,
       department d,
       employee e2
    WHERE
       e.afd = d.anr and
       e.chef = e2.mnr;
    

    Not sure if this helps you better understand how to work the joints.
    Back at you.

    Toon

  • Confused about the complex joins in joins Manager

    Hello

    I know that when we create join in the physical layer, we must use "foreign key" this icon,.

    and when we need create joins in the MDB layer, you need to use 'new joint complex. "

    so, what is the purpose of the complex joined in the Manager of joins? I'm so confused on this subject...

    Kind regards
    Anne

    Hello
    Please see the below a

    http://obiee11gqna.blogspot.com/2011/02/interview-questions-on-joins-in-OBIEE.html

    ---> complex join is that join in join where as two tables has no way join foreign at this complex time key is used

    --> Join complex:-join complex are used in the physical layer between two tables where ever who do not key primary and forgin key relationship.

    Foregin Key:-using the forgin key we can define the join between two tables. joins between is 1:M or M:M., if we want to define: many relationships we use the bridge tables.

    Thank you

    Deva

    Published by: Devarasu on October 18, 2011 10:27

  • [Help] Join the query from 3 tables

    Hi, I'm new to database. I have a question about joining 3 tables, forgive me for my bad English.

    My paintings look like this

    Table 1: person (id, firstname, lastname)
    Table 2: AssignPersonAddress (id, personid, addressid, type)
    Table 3: address (id, phone, street, etc.)

    I need AssignPersonAddress table, because in my data structure, a person may have more than 1 address and address type must be registered (for example: private, work)


    I want to do a select query to the State any person with his private phone and work phone, like this.
    NOBODY | PRIVATE | WORK



    Right now my query looks like this
    select p.name , a1.tel AS Private, a2.tel AS Work
    from person p, 
    addresse a1 , 
    AssignPersonAddress apd1, 
    AssignPersonAddress  apd2, 
    addresse a2
    
    where p.id  = apd1.person (+)
    and apd1.adresse  = a1.id 
    and apd1.art = 'Private' 
    and p.objectid = apd2.person (+)
    and apd2.adresse  = a2.id 
    and apd2.art = 'Work'
    the problem is that I only get the person who has a private address and the job. But what I want is all anyone no matter if the person has only 1 or 2 address.

    As you can see I put the left outer join in where condition, but I always get the wrong result.


    THX in advance


    Danny

    Published by: raitodn on October 1st, 2009 03:51

    Published by: raitodn on October 1st, 2009 04:12
  • JOIN the SQL clause

    Hello

    I have a small question:

    INNER JOIN can be written with just the keyword JOIN?

    For example,.

    INNER JOIN table_b b ON a.col = b.col

    OR

    JOIN table_b b ON a.col = b.col

    Thank you

    Yes it is JOIN table_b b WE a.col = b.col or INNER JOIN table_b b ON a.col = b.col

    Published by: orant575 on June 28, 2009 13:27

  • I want to create new files every 2 seconds of "write in a measurement file.

    I am a beginner of LabVIEW; I want to create new files (with similar names like test_01.txt, test_02.txt...) to 2 seconds interval using "write to a measurement file.

    In fact, it should be a question. Join the program that you have problems with. The subject was discussed several times as you should have found examples when you did your research.

  • Memory management problem

    I have a VI that usually runs for hours, accumulated test data that is displayed in an indicator of the chain. Measure the hours elapse memory consumption ramp VI until finally, due to the slow performance, LabVIEW must be quit and restarted.

    I think my problem is with the way the test data are accumulated. I wrote a small suitcase of VI test to simulate the question and joined 3 pictures, called memory1, memory2 and memory principale3 for illustration.

    In the Memory1.jpg image, LabVIEW has just started but nothing has yet been executed. Note the memory reading as a starting reference point. In Memory2.jpg, the VI had been running for several minutes before, he was arrested. As expected, memory consumption has increased. In Memory3.jpg, click on the Purge button and the VI is executed, the compensation to the channel indicator and the shift register. Note that consumption of memory is wrong, maybe... BUT not all the way back to the consumer memory departure. As I have said again and again this process, the starting point for consumption memory is always greater than the previous run. As the time passes, I find myself with running sluggish VI which can not be repaired until I have quit and restart LabVIEW.

    Is any way to avoid this problem without leaving LabVIEW?

    Thank you!

    When you click on the button "purge", it erases the registry flag and shift but may not necessarily deallocation of memory.

    In my view, that it should reuse however pre-allocated memory.

    If you want to make sure that LabVIEW empty memory previously allocated when you press the purge button, you will need to put your data collector loop in a Subvi and add a 'Request for deletion of allowance' function to execute when you press the purge button inside the Subvi.

    Palette: Application control > control of memory

    I'm not too sure how you build the string in the registry to offset unintialized. This is a classic recipe for a memory leak.

    LabVIEW takes to guess how much memory you need and he must then keep redirect as the size of the string increases. Constantly construction of an array of strings / can be a tedious process and results in fragmented memory.

    You must also use the feature request to remove allocation sparingly, it requires LabVIEW to reallocate memory and can result in a performance hit by having to constantly re - allocate memory it uses.

  • A challenge simple error Bar chart

    Problem is quite simple:

    XY1Err1Y2Err2

    120.130.2

    240.160.2

    360.190.2

    Y1, Y2 on the same plot showing the Err1 error bars and Err2 respectively to draw using the error Bar feature plot, AND (this is the difficulty), make a legend that shows Y1 and Y2 (not the value default Plot0, Plot1, etc.).

    The key is to make the legend by program, dynamically, or what you call, work using the nodes property of the error Bar Plot function. No fancy coding and workaround.

    Looks like I answered my own question. Joined the VI that does exactly what I want!

    For anyone (really novice and beginner) who want to draw multiple curves on the same graph error barcode with error bars y axis and

    the legend to be automatically updated based on the user's specifications, look at my example. See attached VI and the associated trace data.

  • How to create server in Active Directory

    post the anser to * address email is removed from the privacy *.

    Hey Zahurus,

    The Microsoft Answers community focuses on media consumption. For THIS Pro related questions please join the TechNet community for assistance. The link below will take you to Windows Server forum that focuses on Directory Services:
    TechNet - Windows Server - Directory Services

  • Combination 2 + WAV files into one WAV file

    Hello

    I try to combine at least 2 WAV files (my example uses 3) in a single file. I've tried several examples (http://www.jsresources.org/examples/AudioConcat.html and http://stackoverflow.com/questions/653861/join-two-wav-files-from-java), but both have the same problem: the output file is an exact copy of the last file that has been joined.

    Here is the code for the simplest of 2 examples that I modified to suit my needs.
            File outputFile = new File("concat.wav");
            for (int i = 0; i < files.length - 1; i++) {
                try {
                    AudioInputStream clip1 = AudioSystem.getAudioInputStream(files);
    AudioInputStream clip2 = AudioSystem.getAudioInputStream(files[i + 1]);

    AudioInputStream appendedFiles =
    new AudioInputStream(
    new SequenceInputStream(clip1, clip2),
    clip1.getFormat(),
    clip1.getFrameLength() + clip2.getFrameLength());

    AudioSystem.write(appendedFiles,
    AudioFileFormat.Type.WAVE,
    outputFile);

    files[i + 1] = outputFile;//first file read in next loop, will contain joined file so far

    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    return outputFile;


    I am unsure as where the problem lies, so would be grateful for anyone to point out the (no doubt obvious) mistake i've made :p

    I see no problem with your actual code in terms of JavaSound, but...

    The first run through, you'd be concating 'file1.wav' and 'file2.wav' in a file called "concat.wav". The second time, you'd be concating 'concat.wav' and 'file3.wav' in a file called "concat.wav"...

    On the second iteration, "concat.wav" will be put on it until the sequence input stream releases it... What happens as soon as he did read-lock read. At this time, the read lock is released and you can get a lock in writing on this subject, but you have already spilled all concat.wav data in the compartment bits... so the only thing that happens to go there now is "file3.wav".

    So, don't try to read and write to the same file at the same time...

  • Why used it gotoAndStop (1)?

    Hi new here, after playing 2 unloading of film and sound files. the code in a movieclip doesn't seem to want to go back to frame 1!

    I'm out of movieclips with of the "if (then) {gotoAndStop (x);". Yes wht not it?

    Guard trace (_root.finished) impression, Yes, Yes, Yes... loop and waiting

    I expect that I missed something really easy so don't laugh...

    Dee

    onClipEvent (mouseUp) {}

    {callback() function

    _root.finished = "yes";

    clearInterval (callback);

    _root.thumbloader_mc.unloadMovie ("thumbs up.swf");

    trace (_root.finished);

    If (_root.finished == 'Yes') {Stop (1) ;}} Why goto used this framework?

    {

    If ((_root.arrowcardtotal.tharrow == "tharrow" et _root.arrowcardtotal.harrow == "herse") and (_root.arrowcardtotal.tarrow == "tarrow" and _root.arrowcardtotal.uarrow is "uarrow")) {}

    _root.attachMovie ("thumb", "thumb", 0, {_x:350, _y:200});})

    _root.thumbloader_mc.loadMovie ("inches up.swf", 1);

    {

    number = new Sound (this);

    number.attachSound ("well done");

    number.onSoundComplete = function () {trace (' ') ;}}

    Number.Start (0, 1);

    {

    Number1 = new Sound (this);

    Number1.attachSound ("Clapping");

    Number1.onSoundComplete = setInterval (callback, 3000); / / wait

    Number1. Start (0, 1);

    {

    _root.arrowcardtotal.tharrow = "";

    _root.arrowcardtotal.Harrow = "";

    _root.arrowcardtotal.Tarrow = "";

    _root.arrowcardtotal.uarrow = "";

    }

    }}

    }}}

    It is a surprise that the code does something useful.

    the first question, is joining an object code.  delete this onClipEvent().  assign an instance of your object name and use:

    {yourobject.onMouseUp = function ()}

    }

    the second and more important problem is a named function of nesting.  never if you nest a function named.  callback() remove from your nesting and attach it directly to an image.

    Once you have done this, you can start your debugging problems.

    p.s. the onMouseUp event runs whenever the mouse is in place, if the mouse is detected during the stage.  It does not only run when it is clicked on yourobject.  If you want something happens when you mouseup above an object use the onRelease method.

Maybe you are looking for