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. General Programming
  3. C#
  4. about database updation in C#

about database updation in C#

Scheduled Pinned Locked Moved C#
csharpdatabaseannouncement
10 Posts 5 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.
  • V Offline
    V Offline
    Vijaya Deshmukh
    wrote on last edited by
    #1

    :( If I have 2 or more tables in database ,I want to know how we can establish connection between them and if we have same field common in 2 tables ,how we can update all by updating one table i.e. particular fields that r common.

    D OriginalGriffO D 4 Replies Last reply
    0
    • V Vijaya Deshmukh

      :( If I have 2 or more tables in database ,I want to know how we can establish connection between them and if we have same field common in 2 tables ,how we can update all by updating one table i.e. particular fields that r common.

      D Offline
      D Offline
      DX Roster
      wrote on last edited by
      #2

      i am not understanding your question but whatever i got i am telling you.. for making connection you can use join query on table.. If You Get your answer then please Rating me... Thanks.. "Are You Ready" DX-ARMY

      OriginalGriffO 1 Reply Last reply
      0
      • V Vijaya Deshmukh

        :( If I have 2 or more tables in database ,I want to know how we can establish connection between them and if we have same field common in 2 tables ,how we can update all by updating one table i.e. particular fields that r common.

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        UPDATE t1, t2 SET t2.datafield='Table2 data', t1.datafield='Table1 Data' WHERE t1.userID=9 AND t2.userID=9

        You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        • D DX Roster

          i am not understanding your question but whatever i got i am telling you.. for making connection you can use join query on table.. If You Get your answer then please Rating me... Thanks.. "Are You Ready" DX-ARMY

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          AFAIK, JOIN only works for select queries, not for updates - I could be wrong, but I've never seen an UPDATE with a JOIN in!

          You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          D L 2 Replies Last reply
          0
          • OriginalGriffO OriginalGriff

            AFAIK, JOIN only works for select queries, not for updates - I could be wrong, but I've never seen an UPDATE with a JOIN in!

            You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy

            D Offline
            D Offline
            DX Roster
            wrote on last edited by
            #5

            yes you may be right but we can also match the comman field of the table in query..like for example update tablename set ('"+name+"',.....) where table1.id=table2.id and table1.customer_name=table2.customer_name If You Get your answer then please Rating me... Thanks.. "Are You Ready" DX-ARMY

            OriginalGriffO 1 Reply Last reply
            0
            • V Vijaya Deshmukh

              :( If I have 2 or more tables in database ,I want to know how we can establish connection between them and if we have same field common in 2 tables ,how we can update all by updating one table i.e. particular fields that r common.

              D Offline
              D Offline
              DX Roster
              wrote on last edited by
              #6

              you can also use following method update tablename set ('"+name+"',.....) where table1.id=table2.id and table1.customer_name=table2.customer_name If You Get your answer then please Rating me... Thanks.. "Are You Ready" DX-ARMY

              1 Reply Last reply
              0
              • D DX Roster

                yes you may be right but we can also match the comman field of the table in query..like for example update tablename set ('"+name+"',.....) where table1.id=table2.id and table1.customer_name=table2.customer_name If You Get your answer then please Rating me... Thanks.. "Are You Ready" DX-ARMY

                OriginalGriffO Offline
                OriginalGriffO Offline
                OriginalGriff
                wrote on last edited by
                #7

                Indeed - but as the OP question was about updating...

                You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                D 1 Reply Last reply
                0
                • OriginalGriffO OriginalGriff

                  Indeed - but as the OP question was about updating...

                  You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy

                  D Offline
                  D Offline
                  DX Roster
                  wrote on last edited by
                  #8

                  yes your method is correct but i was telling about match two cooman field If You Get your answer then please Rating me... Thanks.. "Are You Ready" DX-ARMY

                  1 Reply Last reply
                  0
                  • OriginalGriffO OriginalGriff

                    AFAIK, JOIN only works for select queries, not for updates - I could be wrong, but I've never seen an UPDATE with a JOIN in!

                    You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy

                    L Offline
                    L Offline
                    loyal ginger
                    wrote on last edited by
                    #9

                    I know at least Microsoft Access and MySQL support joins in UPDATE queries. For your information, go to MySQL's reference page (http://dev.mysql.com/doc/refman/5.0/en/update.html[^]) and search for the word "join" to locate the relating paragraph. I have successfully used UPDATE with join many times. However, not all database systems support this. For example, I have found no support in the small database system "sqlite."

                    1 Reply Last reply
                    0
                    • V Vijaya Deshmukh

                      :( If I have 2 or more tables in database ,I want to know how we can establish connection between them and if we have same field common in 2 tables ,how we can update all by updating one table i.e. particular fields that r common.

                      D Offline
                      D Offline
                      dybs
                      wrote on last edited by
                      #10

                      If the columns in common between the tables have unique values, you can define them as foreign keys with the ON UPDATE CASCADE constraint (assuming the database supports foreign keys - I know SQLite only recently added support for them). When you update the column in the table being referenced, it will automatically update the column in the other table. I'm not certain if it works the other way around, but I think it does. Dybs

                      The shout of progress is not "Eureka!" it's "Strange... that's not what i expected". - peterchen

                      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