sql oracle get all possible values of a lib table











up vote
0
down vote

favorite












I am using sql ORACLE



I have a library table:



libid   libdescr
1 boss
2 secretary
3 manager


And a table with some info:



id  libid   descr
1 1 jim
1 2 james
2 1 rony
2 2 fred
2 3 jana


I want to join both, but I have to have all possible values of the library. So my result have to be:



id  libid   libdescr    descr
1 1 bos jim
1 2 secretary james
1 3 manager <null>
2 1 boss rony
2 2 secretary fred
2 3 manager jana


If I do a join



select info.*,lib.libdescr
from info
left join lib
on lib.libid = info.libid


I don't get the row id=1 and libid=3



How can I make sure I have all the possible values?










share|improve this question


























    up vote
    0
    down vote

    favorite












    I am using sql ORACLE



    I have a library table:



    libid   libdescr
    1 boss
    2 secretary
    3 manager


    And a table with some info:



    id  libid   descr
    1 1 jim
    1 2 james
    2 1 rony
    2 2 fred
    2 3 jana


    I want to join both, but I have to have all possible values of the library. So my result have to be:



    id  libid   libdescr    descr
    1 1 bos jim
    1 2 secretary james
    1 3 manager <null>
    2 1 boss rony
    2 2 secretary fred
    2 3 manager jana


    If I do a join



    select info.*,lib.libdescr
    from info
    left join lib
    on lib.libid = info.libid


    I don't get the row id=1 and libid=3



    How can I make sure I have all the possible values?










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am using sql ORACLE



      I have a library table:



      libid   libdescr
      1 boss
      2 secretary
      3 manager


      And a table with some info:



      id  libid   descr
      1 1 jim
      1 2 james
      2 1 rony
      2 2 fred
      2 3 jana


      I want to join both, but I have to have all possible values of the library. So my result have to be:



      id  libid   libdescr    descr
      1 1 bos jim
      1 2 secretary james
      1 3 manager <null>
      2 1 boss rony
      2 2 secretary fred
      2 3 manager jana


      If I do a join



      select info.*,lib.libdescr
      from info
      left join lib
      on lib.libid = info.libid


      I don't get the row id=1 and libid=3



      How can I make sure I have all the possible values?










      share|improve this question













      I am using sql ORACLE



      I have a library table:



      libid   libdescr
      1 boss
      2 secretary
      3 manager


      And a table with some info:



      id  libid   descr
      1 1 jim
      1 2 james
      2 1 rony
      2 2 fred
      2 3 jana


      I want to join both, but I have to have all possible values of the library. So my result have to be:



      id  libid   libdescr    descr
      1 1 bos jim
      1 2 secretary james
      1 3 manager <null>
      2 1 boss rony
      2 2 secretary fred
      2 3 manager jana


      If I do a join



      select info.*,lib.libdescr
      from info
      left join lib
      on lib.libid = info.libid


      I don't get the row id=1 and libid=3



      How can I make sure I have all the possible values?







      sql oracle






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 at 12:40









      Bigjo

      3191322




      3191322
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote













          In your query either you need to use right join or use the below query :



          select i.*, l.libdescr from lib l left join info i on l.libid=i.libid;             





          share|improve this answer






























            up vote
            0
            down vote













            Use a cross join to generate the rows and a left join to bring in the values from the other table:



            select i.id, l.libid, l.libdescr, s.descr
            from (select distinct id from someinfo) i cross join
            library l left join
            someinfo s
            on s.id = i.id and s.libid = l.libid;





            share|improve this answer





















            • When I do that I get a lot of duplicated values. When I add a distinct I get the desired result, but I am not happy to add a distinct.
              – Bigjo
              Nov 20 at 13:05












            • @Bigjo . . . The duplicate values would presumably be matches in someinfo. You'll have to figure out what you want when there are duplicate rows there.
              – Gordon Linoff
              Nov 20 at 13:10











            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53393219%2fsql-oracle-get-all-possible-values-of-a-lib-table%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote













            In your query either you need to use right join or use the below query :



            select i.*, l.libdescr from lib l left join info i on l.libid=i.libid;             





            share|improve this answer



























              up vote
              1
              down vote













              In your query either you need to use right join or use the below query :



              select i.*, l.libdescr from lib l left join info i on l.libid=i.libid;             





              share|improve this answer

























                up vote
                1
                down vote










                up vote
                1
                down vote









                In your query either you need to use right join or use the below query :



                select i.*, l.libdescr from lib l left join info i on l.libid=i.libid;             





                share|improve this answer














                In your query either you need to use right join or use the below query :



                select i.*, l.libdescr from lib l left join info i on l.libid=i.libid;             






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 21 at 0:30









                Saad

                64111321




                64111321










                answered Nov 20 at 23:28









                Deepak Pant

                111




                111
























                    up vote
                    0
                    down vote













                    Use a cross join to generate the rows and a left join to bring in the values from the other table:



                    select i.id, l.libid, l.libdescr, s.descr
                    from (select distinct id from someinfo) i cross join
                    library l left join
                    someinfo s
                    on s.id = i.id and s.libid = l.libid;





                    share|improve this answer





















                    • When I do that I get a lot of duplicated values. When I add a distinct I get the desired result, but I am not happy to add a distinct.
                      – Bigjo
                      Nov 20 at 13:05












                    • @Bigjo . . . The duplicate values would presumably be matches in someinfo. You'll have to figure out what you want when there are duplicate rows there.
                      – Gordon Linoff
                      Nov 20 at 13:10















                    up vote
                    0
                    down vote













                    Use a cross join to generate the rows and a left join to bring in the values from the other table:



                    select i.id, l.libid, l.libdescr, s.descr
                    from (select distinct id from someinfo) i cross join
                    library l left join
                    someinfo s
                    on s.id = i.id and s.libid = l.libid;





                    share|improve this answer





















                    • When I do that I get a lot of duplicated values. When I add a distinct I get the desired result, but I am not happy to add a distinct.
                      – Bigjo
                      Nov 20 at 13:05












                    • @Bigjo . . . The duplicate values would presumably be matches in someinfo. You'll have to figure out what you want when there are duplicate rows there.
                      – Gordon Linoff
                      Nov 20 at 13:10













                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    Use a cross join to generate the rows and a left join to bring in the values from the other table:



                    select i.id, l.libid, l.libdescr, s.descr
                    from (select distinct id from someinfo) i cross join
                    library l left join
                    someinfo s
                    on s.id = i.id and s.libid = l.libid;





                    share|improve this answer












                    Use a cross join to generate the rows and a left join to bring in the values from the other table:



                    select i.id, l.libid, l.libdescr, s.descr
                    from (select distinct id from someinfo) i cross join
                    library l left join
                    someinfo s
                    on s.id = i.id and s.libid = l.libid;






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 20 at 12:43









                    Gordon Linoff

                    753k35286395




                    753k35286395












                    • When I do that I get a lot of duplicated values. When I add a distinct I get the desired result, but I am not happy to add a distinct.
                      – Bigjo
                      Nov 20 at 13:05












                    • @Bigjo . . . The duplicate values would presumably be matches in someinfo. You'll have to figure out what you want when there are duplicate rows there.
                      – Gordon Linoff
                      Nov 20 at 13:10


















                    • When I do that I get a lot of duplicated values. When I add a distinct I get the desired result, but I am not happy to add a distinct.
                      – Bigjo
                      Nov 20 at 13:05












                    • @Bigjo . . . The duplicate values would presumably be matches in someinfo. You'll have to figure out what you want when there are duplicate rows there.
                      – Gordon Linoff
                      Nov 20 at 13:10
















                    When I do that I get a lot of duplicated values. When I add a distinct I get the desired result, but I am not happy to add a distinct.
                    – Bigjo
                    Nov 20 at 13:05






                    When I do that I get a lot of duplicated values. When I add a distinct I get the desired result, but I am not happy to add a distinct.
                    – Bigjo
                    Nov 20 at 13:05














                    @Bigjo . . . The duplicate values would presumably be matches in someinfo. You'll have to figure out what you want when there are duplicate rows there.
                    – Gordon Linoff
                    Nov 20 at 13:10




                    @Bigjo . . . The duplicate values would presumably be matches in someinfo. You'll have to figure out what you want when there are duplicate rows there.
                    – Gordon Linoff
                    Nov 20 at 13:10


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53393219%2fsql-oracle-get-all-possible-values-of-a-lib-table%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    404 Error Contact Form 7 ajax form submitting

                    How to know if a Active Directory user can login interactively

                    TypeError: fit_transform() missing 1 required positional argument: 'X'