[MySQL 3.23.X] In UPDATE ein JOIN?

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • [MySQL 3.23.X] In UPDATE ein JOIN?

    ... ist das möglich?

    Möchte gerne so was in der Art machen:
    UPDATE tabelle1,tabelle2 SET tabelle1.id_tabelle2 = tabelle2.id_tabelle2 WHERE tabelle2.id = tabelle1.id;

    bzw.:
    UPDATE tabelle1 LEFT JOIN tabelle2 SET tabelle1.id_tabelle2 = tabelle2.id_tabelle2 WHERE tabelle2.id = tabelle1.id;

    Ich möchte alle tabelle1.id_tabelle2 ändern, wo tabelle2.id = tabelle1.id

    Klappt nur leider nicht.

    http://www.mysql.de/doc/de/UPDATE.html
    <- ist das wirklich alles was man mit UPDATE machen kann?

    Nachtrag:
    Sieht schlecht aus
    http://www.mysql.com/doc/de/TODO_future.html
    Zuletzt geändert von Sebastian W; 13.02.2004, 09:13.
    Grüsse,
    Sebastian


    Profil Flex Freelancer
    Twitter twitter.com/flashhilfe
    Web Flash und Flex Community

  • #2
    [MySQL 3.23.X] In UPDATE ein JOIN?
    ... ist das möglich?
    nein. aber das hast du glaube ich schon selber rausgefunden....
    INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


    Kommentar


    • #3
      Ja. Aber wirklich schade das es nicht geht.

      Lös es jetzt mit zwei Querys. Falls es jemanden interessiert:

      PHP-Code:
      $result mysql_query("SELECT p1.id, p2.id_tabelle2 FROM tabelle2 p1 LEFT JOIN tabelle1 p2 ON p1.id = p2.id");
      while(
      $daten mysql_fetch_array($result)) {
          
      $sql "UPDATE tabelle1 SET id_tabelle2 = '" $daten['id_tabelle2'] . "' WHERE id = '" $daten['id'] . "'";
          
      mysql_query($sql);
          
      flush();

      Grüsse,
      Sebastian


      Profil Flex Freelancer
      Twitter twitter.com/flashhilfe
      Web Flash und Flex Community

      Kommentar


      • #4
        Original geschrieben von Sebastian W
        Ja. Aber wirklich schade das es nicht geht.
        tja. die 3er version eben....
        INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


        Kommentar

        Lädt...
        X