How do I combine multiple mysql queries in wpdatatables? For example, the following two queries first sets a variable to zero and then retrieves the cumulative sum:
SET @runtot:=0; SELECT q1.d, q1.c, (@runtot := @runtot + q1.c) AS rt FROM (SELECT DATE_FORMAT(LocalDateTime, "%Y-%m") AS d, SUM(datavalue) AS c FROM datavalues WHERE VariableID=73 GROUP BY DATE_FORMAT(LocalDateTime, "%Y-%m")) AS q1;
However, wpdatatables won't allow combined queries, returning a "wpDataTables backend error".
Unfortunately using MySQL Variables is not possible to use in wpDataTables. Maybe you can create MySQL VIew in phpMyAdmin or any other database administration tool that you are using and after that create wpDataTable from that MySQL View.
You can take a look at this tutorial how you can create MySQL View - Link. After that you can create table from this query:
How do I combine multiple mysql queries in wpdatatables? For example, the following two queries first sets a variable to zero and then retrieves the cumulative sum:
SET @runtot:=0;
SELECT
q1.d,
q1.c,
(@runtot := @runtot + q1.c) AS rt
FROM
(SELECT
DATE_FORMAT(LocalDateTime, "%Y-%m") AS d,
SUM(datavalue) AS c
FROM datavalues
WHERE VariableID=73
GROUP BY DATE_FORMAT(LocalDateTime, "%Y-%m")) AS q1;
However, wpdatatables won't allow combined queries, returning a "wpDataTables backend error".
Thank you!
Hi Rich,
Thank you for your purchase.
Unfortunately using MySQL Variables is not possible to use in wpDataTables. Maybe you can create MySQL VIew in phpMyAdmin or any other database administration tool that you are using and after that create wpDataTable from that MySQL View.
You can take a look at this tutorial how you can create MySQL View - Link. After that you can create table from this query:
Kind Regards,
Miloš Jovanović
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables