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.

Empfohlene Antworten

Veröffentlicht

Hallo,

ich benötige mal die Hilfe eines versierten SQL Programmierers:

Ich betreibe einen Webshop und würde gerne über ein SQL Script meine Staffelpreise anpassen können – dies geht leider von Werk aus nicht..

Es gibt zwei Tabellen:

products:

	  
products_id products_price

1 6.9800
2 6.9800
[/PHP]

und

[b]grad_price[/b]:

[PHP]
price_id products_id quantity personal_offer

3761 1 1 6.9800
3762 1 3 6.2820
3763 1 5 5.9330
3766 2 5 5.9330
3765 2 3 6.2820
3764 2 1 6.9800

Mein Wunsch wäre nun dass ich ein mySQLadmin oder PHP Script hätte bei dem ich Angebe:

products_id : 1

new_price: 10.00

Das Script verknüpft die Tabellen anhand des products_id Primärschlüssels und ändert in

a) products: products_price den preis auf 10.00

B) grad_price für quantity 1 den Preis auf 10.00

c) grad_price für quantity 3 den Preis auf 10.00 *0,9

d) grad_price für quantity 5 den Preis auf 10.00 *0.85

Ich kenne mich leider nicht mit SQL so gut aus - dass ich das nun runterschreiben könnte.

Vielleicht hat ja jemand eine Lösung parat.

Vielen Dank!

:)

Sind die Staffelungen immer gleich? Du musst dafür schon für jede Staffel einen prozentualen Wert kennen.

Wenn es Ausnahmefälle gibt, wird es schwierig. Dann würden die Eingansparameter nicht ausreichen.

Prinzipiell würde ich das als recht trivial einschätzen. Ob das jetzt fixe Preisnachlässe sind, oder ob die Preisnachlässe einen Default für alle Produkte, mit der Möglichkeit für einzelne Produkte den Default zu überschreiben .... ist recht einfach gemacht.

Ich frag mich aber, warum sollte ich einem komerziellen Betreiber eines Webshops (Webshop is für mich kommerziell), ein SQL Skript eben runterschreiben ?

Auf die Frage würde ich mit "was zahlst du ?" antworten.

Gruß

Sven

... Es winkt ein 30€ Amazon Gutschein.

Die Preisnachlässe sind immer fix wie oben angegebenen.

Gruß

Bearbeitet von bublabla

Sven war so nett mir zu helfen.

Gruß

mache ich,

muss es erst noch testen ..

  • 3 Wochen später...


SET @product_id = ?

SET @new_price = ?



UPDATE products 

SET products_price = @new_price 

WHERE products_id = @product_id;


UPDATE gp

SET personal_offer = CASE 

							WHEN quantity >= 5 THEN prod.product_price * 0.85

							WHEN quantity >= 3 THEN prod.product_price * 0.9

							ELSE quantity THEN prod.product_price

					END

FROM grad_price as gp INNER JOIN products prod ON gp.products_id =prod.products_id					

WHERE prod.products_id = @product_id;

Ich habs nie getestet .... aber sollte meinem Dafürhalten nach funktionieren

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

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.