Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to insert values in to one table, data from two different tables?

How to insert values in to one table, data from two different tables?

Scheduled Pinned Locked Moved Database
tutorialquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sarala s
    wrote on last edited by
    #1

    Hi, I am having 3 tables... in the third table(Table C) i want to insert the values... which i am having datas( some datas not all) in the first(Table A) and second table(some vales not all) (Table B), by single insert.... how to do this??..

    T B 2 Replies Last reply
    0
    • S sarala s

      Hi, I am having 3 tables... in the third table(Table C) i want to insert the values... which i am having datas( some datas not all) in the first(Table A) and second table(some vales not all) (Table B), by single insert.... how to do this??..

      T Offline
      T Offline
      thatraja
      wrote on last edited by
      #2

      Try something like

      INSERT INTO TableC SELECT TableA.Field, TableB.Field FROM TableA, TableB

      thatraja


      Tips/Tricks|Brainbench certifications|Facebook|Twitter

      1 Reply Last reply
      0
      • S sarala s

        Hi, I am having 3 tables... in the third table(Table C) i want to insert the values... which i am having datas( some datas not all) in the first(Table A) and second table(some vales not all) (Table B), by single insert.... how to do this??..

        B Offline
        B Offline
        Blue_Boy
        wrote on last edited by
        #3

        INSERT INTO TABLEC
        SELECT tableb.col1,tableb.col1 FROM tablea, tableb


        I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

        L 1 Reply Last reply
        0
        • B Blue_Boy

          INSERT INTO TABLEC
          SELECT tableb.col1,tableb.col1 FROM tablea, tableb


          I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

          L Offline
          L Offline
          lovejun
          wrote on last edited by
          #4

          if there no restrictions of this script,there must have some repeat results,like if the tableb have 3 rows,the tablec have 3 rows,there will be exists 9 rows,how to solve this? :confused:

          B 1 Reply Last reply
          0
          • L lovejun

            if there no restrictions of this script,there must have some repeat results,like if the tableb have 3 rows,the tablec have 3 rows,there will be exists 9 rows,how to solve this? :confused:

            B Offline
            B Offline
            Blue_Boy
            wrote on last edited by
            #5

            My previous post for this thread was only example how to do the insert from select statement. For more specified case then it must have other conditions on select statement and so. :)


            I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups