Need MySQL help with short query..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pics Traffic
    Confirmed User
    • Jun 2004
    • 3055

    #1

    Need MySQL help with short query..

    I have two tables A and B. I want update table A with all entries from table B. Tables have different structures but 2 colums that I want to copy are the same. Help brother out.
    My Network Is Waiting For Your Fuckin' Trade!
  • rowan
    Too lazy to set a custom title
    • Mar 2002
    • 17393

    #2
    If you're ever scratching your head about a command, do a search for "COMMAND mysql" and the mysql site is usually the first result.

    I presume you want something like this...

    INSERT INTO table_B (column1,column2) SELECT column1,column2 FROM table_A;

    Back up your data first.

    Comment

    • Pics Traffic
      Confirmed User
      • Jun 2004
      • 3055

      #3
      Originally posted by rowan
      If you're ever scratching your head about a command, do a search for "COMMAND mysql" and the mysql site is usually the first result.

      I presume you want something like this...

      INSERT INTO table_B (column1,column2) SELECT column1,column2 FROM table_A;

      Back up your data first.
      sorry, I should have added that I need to do UPDATE not insert because there's a default value in that field already. I looked all over but still can't figure out what Im doing wrong.
      My Network Is Waiting For Your Fuckin' Trade!

      Comment

      • Pics Traffic
        Confirmed User
        • Jun 2004
        • 3055

        #4
        Ok, case closed. Figured it out.
        My Network Is Waiting For Your Fuckin' Trade!

        Comment

        • rowan
          Too lazy to set a custom title
          • Mar 2002
          • 17393

          #5
          So what was the answer? REPLACE INTO?

          Comment

          • Iron Fist
            Too lazy to set a custom title
            • Dec 2006
            • 23400

            #6
            Love these threads...

            HELP ME HELP ME...

            Okay FUCK OFF... I GOT IT...

            Yeech... at least post what you did that fixed it.
            i like waffles

            Comment

            • Pics Traffic
              Confirmed User
              • Jun 2004
              • 3055

              #7
              Originally posted by rowan
              So what was the answer? REPLACE INTO?
              no, just update.. I was overdoing it. It was easy one.

              UPDATE videos v, banners b SET v.BANNER_NAME = b.BANNER_NAME, v.BANNER_URL = b.BANNER_URL WHERE v.VIDEOID = b.VIDEOID
              My Network Is Waiting For Your Fuckin' Trade!

              Comment

              Working...