Jump to content

SQL Datenbank Abfrage - Lieferadresse


ianmoone

Recommended Posts

Hallo, ich rufe mit folgender Abfrage die Daten zu meinen Bestellungen ab um sie in einer Liste weiter zu verwenden. Ich würde gerne die Lieferadresse mit Abrufen, finde aber leider nicht wo diese gespeichert ist..

 

SELECT d.id_order, os.name AS Status, d.product_name AS Produkt, ROUND(d.product_price,2) AS Preis, d.product_quantity AS Menge, o.payment AS Bezahlung, o.date_upd AS Datum, CONCAT_WS(' ', a.firstname, a.lastname) AS Kunde, a.address1 AS Strasse, a.postcode AS PLZ, a.city AS Ort, cl.name AS Lande, gl.name AS Kundengruppe
    FROM d72nF_order_detail d
    LEFT JOIN d72nF_orders o ON (d.id_order = o.id_order)
    LEFT JOIN d72nF_customer g ON (o.id_customer = g.id_customer)
    LEFT JOIN d72nF_address AS a ON (o.id_customer = a.id_customer)
    LEFT JOIN d72nF_country_lang AS cl ON (a.id_country = cl.id_country )
    LEFT JOIN d72nF_group_lang gl ON (g.id_default_group = gl.id_group)
    LEFT JOIN d72nF_order_state_lang os ON (o.current_state = os.id_order_state)

GROUP by  CONCAT_WS(' ', d.product_name, g.lastname, g.firstname,d.id_order ) 
ORDER BY d.id_order DESC

 

Link to comment
Share on other sites

WHERE a.id_address = o.id_address_delivery

SELECT d.id_order, os.name AS Status, d.product_name AS Produkt, ROUND(d.product_price,2) AS Preis, d.product_quantity AS Menge, o.payment AS Bezahlung, o.date_upd AS Datum, CONCAT_WS(' ', a.firstname, a.lastname) AS Kunde, a.address1 AS Strasse, a.postcode AS PLZ, a.city AS Ort, cl.name AS Lande, gl.name AS Kundengruppe
    FROM d72nF_order_detail d
    LEFT JOIN d72nF_orders o ON (d.id_order = o.id_order)
    LEFT JOIN d72nF_customer g ON (o.id_customer = g.id_customer)
    LEFT JOIN d72nF_address AS a ON (o.id_customer = a.id_customer)
    LEFT JOIN d72nF_country_lang AS cl ON (a.id_country = cl.id_country )
    LEFT JOIN d72nF_group_lang gl ON (g.id_default_group = gl.id_group)
    LEFT JOIN d72nF_order_state_lang os ON (o.current_state = os.id_order_state)
WHERE a.id_address = o.id_address_delivery
GROUP by  CONCAT_WS(' ', d.product_name, g.lastname, g.firstname,d.id_order ) 
ORDER BY d.id_order DESC;
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...