data fetch and insert

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prasadshete
    New Member
    • Feb 2007
    • 19

    #1

    data fetch and insert

    hello all,
    i want to fetch data from one colomn and copy it to the column in a different table..the database is postgres.
    please tell me how to do it..
    thanks and regards,
  • michaelb
    Recognized Expert Contributor
    • Nov 2006
    • 534

    #2
    Either one from the two examples below should work for you:

    Code:
    INSERT into tableA (columnB)  SELECT columnX FROM tableY;
    -- a minor cosmetic touch
    INSERT into tableA (columnB)  (SELECT columnX FROM tableY);
    You can read more on the subject here

    Comment

    • prasadshete
      New Member
      • Feb 2007
      • 19

      #3
      thank you for you reply..
      actually i have made a mistake in the perception of a problem..
      actually i have to update a column which is newly created
      i am fetching the records from one column like names
      and after making them all capital and removing any unusual character other thaN
      alphabets i want them in anothe culumn which is newly created..
      so the question is will i have to use insert query or update query
      i am confused about the insert and update queries
      plz guide me in this regard
      thanx


      Originally posted by michaelb
      Either one from the two examples below should work for you:

      Code:
      INSERT into tableA (columnB)  SELECT columnX FROM tableY;
      -- a minor cosmetic touch
      INSERT into tableA (columnB)  (SELECT columnX FROM tableY);
      You can read more on the subject here

      Comment

      • michaelb
        Recognized Expert Contributor
        • Nov 2006
        • 534

        #4
        Do these two columns, the source and the target, both belong to the same table?

        Comment

        • prasadshete
          New Member
          • Feb 2007
          • 19

          #5
          yes
          they belong to the same table, and
          after making them caps and removing
          the numbers present in name i want
          to check it from anther database and if the name
          in these two databases are same then
          i want to give the the id
          related with the name in first database



          Originally posted by michaelb
          Do these two columns, the source and the target, both belong to the same table?

          Comment

          Working...