Fetch records of postgres and store it in different table , if one column is null





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I have a table employee(id,empname,salary,dob)
If the record of id and empname is null..whole record should be removed in different table...



For example.....



 id  | empname |salary | year
_____________________________
101 | ishi |100000 | null
null | aarush |200000 | 4
102 | rkr |2000000| 6
104 |null |300000 | 3
105 |null |400000 | 3


If Id column has null value..the record should be fetch and placed in different table say null_table ...same case for empname column
the rest record should be placed in different table say success_table



The output should be



success_table:



 id  | empname |salary | year
_____________________________
101 | ishi |100000 | null
102 | rkr |2000000| 6


null_table:



 id  | empname |salary | year
_____________________________
null | aarush |200000 | 4
104 |null |300000 | 3
105 |null |400000 | 3


I am new to postgres...Any suggestions are appreciated...









share







New contributor




ishika is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



























    0















    I have a table employee(id,empname,salary,dob)
    If the record of id and empname is null..whole record should be removed in different table...



    For example.....



     id  | empname |salary | year
    _____________________________
    101 | ishi |100000 | null
    null | aarush |200000 | 4
    102 | rkr |2000000| 6
    104 |null |300000 | 3
    105 |null |400000 | 3


    If Id column has null value..the record should be fetch and placed in different table say null_table ...same case for empname column
    the rest record should be placed in different table say success_table



    The output should be



    success_table:



     id  | empname |salary | year
    _____________________________
    101 | ishi |100000 | null
    102 | rkr |2000000| 6


    null_table:



     id  | empname |salary | year
    _____________________________
    null | aarush |200000 | 4
    104 |null |300000 | 3
    105 |null |400000 | 3


    I am new to postgres...Any suggestions are appreciated...









    share







    New contributor




    ishika is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I have a table employee(id,empname,salary,dob)
      If the record of id and empname is null..whole record should be removed in different table...



      For example.....



       id  | empname |salary | year
      _____________________________
      101 | ishi |100000 | null
      null | aarush |200000 | 4
      102 | rkr |2000000| 6
      104 |null |300000 | 3
      105 |null |400000 | 3


      If Id column has null value..the record should be fetch and placed in different table say null_table ...same case for empname column
      the rest record should be placed in different table say success_table



      The output should be



      success_table:



       id  | empname |salary | year
      _____________________________
      101 | ishi |100000 | null
      102 | rkr |2000000| 6


      null_table:



       id  | empname |salary | year
      _____________________________
      null | aarush |200000 | 4
      104 |null |300000 | 3
      105 |null |400000 | 3


      I am new to postgres...Any suggestions are appreciated...









      share







      New contributor




      ishika is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I have a table employee(id,empname,salary,dob)
      If the record of id and empname is null..whole record should be removed in different table...



      For example.....



       id  | empname |salary | year
      _____________________________
      101 | ishi |100000 | null
      null | aarush |200000 | 4
      102 | rkr |2000000| 6
      104 |null |300000 | 3
      105 |null |400000 | 3


      If Id column has null value..the record should be fetch and placed in different table say null_table ...same case for empname column
      the rest record should be placed in different table say success_table



      The output should be



      success_table:



       id  | empname |salary | year
      _____________________________
      101 | ishi |100000 | null
      102 | rkr |2000000| 6


      null_table:



       id  | empname |salary | year
      _____________________________
      null | aarush |200000 | 4
      104 |null |300000 | 3
      105 |null |400000 | 3


      I am new to postgres...Any suggestions are appreciated...







      postgresql





      share







      New contributor




      ishika is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      ishika is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      ishika is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 mins ago









      ishikaishika

      1




      1




      New contributor




      ishika is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      ishika is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      ishika is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "182"
          };
          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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
          });


          }
          });






          ishika is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f234391%2ffetch-records-of-postgres-and-store-it-in-different-table-if-one-column-is-nul%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          ishika is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          ishika is a new contributor. Be nice, and check out our Code of Conduct.













          ishika is a new contributor. Be nice, and check out our Code of Conduct.












          ishika is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Database Administrators Stack Exchange!


          • 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%2fdba.stackexchange.com%2fquestions%2f234391%2ffetch-records-of-postgres-and-store-it-in-different-table-if-one-column-is-nul%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

          Liste der Baudenkmale in Friedland (Mecklenburg)

          Single-Malt-Whisky

          Czorneboh