Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Update-Statement

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

irgendwie stehe ich total auf dem Schlauch. Ich versuche folgendes Statement an MySQL abzusetzen:

UPDATE hc_price SET price.doPrice=price.doPrice * 0.9 FROM hc_price price,hc_article art WHERE price.FK_ARTICLE_ID=art.nID AND art.nMainMaterialGroup=794 AND price.nCatalogId=14 AND price.FK_LANGUAGE_ID=1

bekomme aber immer die Fehlermeldung:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM hc_price price,hc_article art WHERE price.FK_ARTICLE_ID=art.nID AND art.nMa' at line 1

und irgendwie bekomme ich das nicht auf die Reihe. Was mach ich denn falsch???

Grüße

Timo

Ich hab keine Ahnung wie das bei MySQL umgesetzt ist, aber ich gehe davon aus, dass auch dort Subquerys geklammert werden muessen.

Goos

PS: Ein select muss dann natuerlich auch noch rein ;)

UPDATE hc_price SET price.doPrice=price.doPrice * 0.9 FROM hc_price price,hc_article art WHERE (price.FK_ARTICLE_ID=art.nID) AND( art.nMainMaterialGroup=794) AND (price.nCatalogId=14) AND price.FK_LANGUAGE_ID=1

Klammere mal die einzelnen Statements zwischen den AND Operatoren.

Bin aber kein MySql Spezialist


UPDATE

     hc_price

SET

     price.doPrice = price.doPrice * 0.9

FROM

     hc_price, price, hc_article, art

WHERE

     price.FK_ARTICLE_ID = art.nID AND

     art.nMainMaterialGroup = 794 AND

     price.nCatalogId = 14 AND

     price.FK_LANGUAGE_ID = 1


UPDATE

     hc_price

SET

     price.doPrice = price.doPrice * 0.9

FROM

     hc_price, price, hc_article, art

WHERE

     price.FK_ARTICLE_ID = art.nID AND

     art.nMainMaterialGroup = 794 AND

     price.nCatalogId = 14 AND

     price.FK_LANGUAGE_ID = 1

Was soll nun das?

Meinst du wirklich, dass es an den Zeilenumbruechen und Leerzeichen haengt?

Falls das so ist, dann pack ich schonmal meinen Essbesen aus und werden in Zukunft jedem von MySQL abraten :D

Goos

wenn ich da richtig durchgestiegen bin dachte ich eigentlich an die kommas

wenn ich da richtig durchgestiegen bin dachte ich eigentlich an die kommas

Ach so, mein Fehler... die hab ich nicht gesehen :bimei

Deine zusaetzlichen Kommas gehoeren da aber nicht rein. An der Stelle werden nur Tabellenaliasse vergeben.

Goos

die syntax ist flasch


UPDATE tabelle 

SET spalte = (SELECT spalte*0.9 AS bla FROM tabelle WHERE bedingung)

WHERE

bedingung fuer das update

waere richtig

Ted

Er braucht doch gar kein SELECT, wenn es sich eh um dieselbe Tabelle handelt...

Also


UPDATE hc_price SET doPrice= doPrice * 0.9

WHERE FK_ARTICLE_ID=[b]X[/b] AND nCatalogId=14 AND FK_LANGUAGE_ID=1

Dabei muss die Artikel ID (das X oben) eben vorher bestimmt werden. Updates funktionieren eigentlich immer nur mit 1 Tabelle im Statement.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.