How to SELECT and JOIN from three tables when VIEW is not feasible

How to SELECT and JOIN from three tables when VIEW is not feasible

sebfdsebfd Posts: 5Questions: 2Answers: 0

I am very new to web programming, SQL and Editor in particular. So I haven't hat the chance to get a broad view over all related topics yet.
I have the following problem to solve:

I have one master table with columns that contain (SUM, MAX) values from two other tables. Some columns need to be editable (not the ones that refer to other tables), which is why I cannot use a VIEW, if I am informed correctly.

The SQL query is this:

SELECT
d.Name, d.KundenNr, SUM(z.betrag), MAX(z.Datum),
(SELECT DATE_ADD(Rechnungsdatum, INTERVAL m.f1 DAY) FROM mahnfristen AS m WHERE m.Kunde=d.Kunde) AS D1Mahnung,
(SELECT DATE_ADD(Rechnungsdatum, INTERVAL m.f2 DAY) FROM mahnfristen AS m WHERE m.Kunde=d.Kunde) AS D2Mahnung
FROM debiliste2 d
LEFT JOIN zahlungen z ON d.KundenNr = z.sID
GROUP BY d.ID;

So how do I get this into an Editor Datatable?
Thank you very much!

Answers

  • allanallan Posts: 62,994Questions: 1Answers: 10,368 Site admin

    I'm afraid the provided libraries (PHP, .NET and Node) do not support GROUP BY so there is no way to use those libraries to read and write such a structure. You'd need to either use different code on the server-side (the client-side would cope with this fine) or read from a different source (i.e. a VIEW) and then update directly to the table.

    Allan

  • sebfdsebfd Posts: 5Questions: 2Answers: 0

    allan, thanks for your reply. How can I use different code on the server-side or how do I seperate the non-editable view from the updatable table? I scanned the forums and the documentation for this, but I don't know where to go, Could you provide me with some hints maybe?

    THank you very much!

This discussion has been closed.