Forums

SQL DATABASE action in CF7

Fredolino 27 May, 2024

Hello,

I would like to use the SQL Data Action in CF 7 and use the result in a Table List. I looked at the tutorial from Colnem. But I didn't really understand it.I need 2 database tables for the query.Do I then have to create 2 sql_data and a 3rd sql_data for the joins?

Fred

Currently this is my SQL query for the database:

SELECT
    CONCAT_WS(' ', Artname.gattung, Artname.art, Artname.autor, Artname.artname_de) AS SpecName,
    SUM(StatDataR.Total) AS MonthlyTotal,
    StatDataR.Species,
    StatDataR.Month,
    StatDataR.Year
FROM
    mtb_SpecPerMonthYearView AS StatDataR
LEFT JOIN
    mtb_hauptliste AS Artname ON StatDataR.Species = Artname.art_id
LEFT JOIN
    mtb_beobachtung_art AS BeoArt ON StatDataR.Species = BeoArt.art_id
WHERE
    StatDataR.Species = '7563'
    AND StatDataR.Year >= '2000'
    AND BeoArt.nachweis_id = '7'
    AND BeoArt.stadium_id = '4'
GROUP BY
    StatDataR.Month,
    StatDataR.Species,
    StatDataR.Year
ORDER BY
    StatDataR.Month ASC;
You need to login to be able to post a reply.