SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    can you UPDATE two tables in a single SQL statement using INNER JOIN for two tables

    As I undertstand INNER JOINs, once joined they are like one big table. So Can you UPDATE or INSERT two (or more) tables in a single SQL statement using INNER JOINs?

    Thanks.

    first edit
    ========================================
    After thinking it a little more, of course you can't because there's nothing to join on! brain-cramp

  2. #2
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For UPDATES

    Short answer - YES

    Long answer - http://dev.mysql.com/doc/mysql/en/UPDATE.html

    For INSERTS - No

  3. #3
    SitePoint Guru asterix's Avatar
    Join Date
    Jun 2003
    Posts
    847
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, you can't.
    You can only ever modify (update, delete, insert) one table at a time.

  4. #4
    SitePoint Guru asterix's Avatar
    Join Date
    Jun 2003
    Posts
    847
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by swdev
    For UPDATES

    Short answer - YES

    Long answer - http://dev.mysql.com/doc/mysql/en/UPDATE.html

    For INSERTS - No
    Just a second, they *do not* say you can update several tables with one statement.

    Multi-Table updates do not update multiple tables!
    They are used only to return a subset of the table containing the rows to be modified based on the join.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •