software:mysql:withrecursive
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| software:mysql:withrecursive [2026/02/06 22:01] – rodolico | software:mysql:withrecursive [2026/02/06 22:05] (current) – rodolico | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== The WITH RECURSIVE syntax ====== | ====== The WITH RECURSIVE syntax ====== | ||
| - | Using FrontAccounting (https:// | + | Using [[https:// |
| ===== Warnings ===== | ===== Warnings ===== | ||
| - | Just like it says, this is recursion, generally used to retrieve data from a hierarchial | + | Just like it says, this is recursion, generally used to retrieve data from a hierarchical |
| - | It is very resource intensive if it has to recurse very deep. Be careful when implenting | + | It is very resource intensive if it has to recurse very deep. Be careful when implementing |
| ===== Original Task ===== | ===== Original Task ===== | ||
| - | The basic query, after some looking around, turned out to be: | + | After some looking around, |
| <code sql> | <code sql> | ||
| Line 31: | Line 31: | ||
| </ | </ | ||
| - | I then ran the output of this through a Perl script | + | I then ran the output of this through a Perl script |
| - | I was able to bypass the Perl script by learning the new CTE (Common Table Expressions) syntax for MySQL (and MariaDB). This is similar to processing queries into temp tables, then running an additional query against them. | + | I was able to bypass the Perl script by learning the CTE (Common Table Expressions) syntax for MySQL (and MariaDB). This is similar to processing queries into temp tables, then running an additional query against them. |
| ===== Solution ===== | ===== Solution ===== | ||
| Line 103: | Line 103: | ||
| </ | </ | ||
| - | | + | * This projects 12 months |
| - | * Our invoicing is done on the 15th of every month, so in three locations, we have that hard coded also. Look for //' | + | |
| ===== Explanation ===== | ===== Explanation ===== | ||
| Line 140: | Line 140: | ||
| The result returns one row per month: | The result returns one row per month: | ||
| - | * '' | + | * '' |
| * '' | * '' | ||
| Line 147: | Line 147: | ||
| <code sql> | <code sql> | ||
| - | DATE_ADD(DATE_FORMAT(MIN(nextDue), | + | DATE_ADD(DATE_FORMAT(MIN(nextDue), |
| </ | </ | ||
software/mysql/withrecursive.1770436883.txt.gz · Last modified: by rodolico
