Proper SQL String

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wisni1rr
    New Member
    • Nov 2011
    • 78

    #1

    Proper SQL String

    I'm a novice to mySQL. I am looking for help to develop a query that will add data to an existing tableA.

    The query should check fieldA of tableA (also the PK)and check it against the fieldA (the same PK)in my dump. If they match, then my dump file would update fieldX, fieldY, and fieldZ on tableA from my dump fieldB, fieldC, fieldD.

    If it is easier to do a column at a time that is acceptable.

    How would you construct such a query?
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You would use an update query where you join the tables together on the PK.

    Comment

    • Luuk
      Recognized Expert Top Contributor
      • Mar 2012
      • 1043

      #3
      more about the how to do the update is here, to join the tables you can find info here

      after reading, and studying, you should get something like (intested)
      Code:
      UPDATE tableA A 
      INNER jOIN tableB B ON A.fieldA=B.fieldA 
        SET A.fieldX=B.fieldB, 
        A.fielY=B.fieldC, 
        A.fieldZ=B.fieldD;

      Comment

      Working...