# [16-Nov-2022 08:50:38] /photonics/www/bg/събития.html 167.99.142.201

set names utf8

SELECT
                *
	        FROM
	        	`pages`
	    	WHERE
	    		`URLLabel` = 'събития' AND
                (`ExternalURL` IS NULL OR `ExternalURL` = '')
         AND `Visible` = 1 LIMIT 1

SELECT
	        	*
	        FROM
	        	`events`
	    	WHERE 1
         AND `Visible` = 1 ORDER BY `PostDate` ASC

SELECT
                `pages`.`ID`,
                `pages`.`ParentID`,
                `pages`.`MenuLabel`,
                `pages`.`URLLabel`,
                `pages`.`ExternalURL`,
                `SubPages`.`ID` AS `SubPageID`
            FROM
                `pages`
                LEFT JOIN `pages` AS `SubPages` ON `pages`.`ID` = `SubPages`.`ParentID` AND `SubPages`.`Visible` = 1 WHERE `pages`.`MenuLabel` <> ''  AND `pages`.`Visible` = 1
            GROUP BY
                `pages`.`ID`
            ORDER BY
                `pages`.`ParentID` ASC,
                `pages`.`PostDate` ASC

SELECT
                `pages`.`ID`,
                `pages`.`ParentID`,
                `pages`.`FooterLabel`,
                `pages`.`URLLabel`,
                `pages`.`ExternalURL`,
                `SubPages`.`ID` AS `SubPageID`
            FROM
                `pages`
                LEFT JOIN `pages` AS `SubPages` ON `pages`.`ID` = `SubPages`.`ParentID` AND `SubPages`.`Visible` = 1 WHERE `pages`.`FooterLabel` <> ''  AND `pages`.`Visible` = 1
            GROUP BY
                `pages`.`ID`
            ORDER BY
                `pages`.`ParentID` ASC,
                `pages`.`PostDate` ASC
# [16-Nov-2022 14:37:23] /photonics/www/bg/купи-билет.html 167.99.142.201

set names utf8

SELECT
                *
	        FROM
	        	`pages`
	    	WHERE
	    		`URLLabel` = 'купи-билет' AND
                (`ExternalURL` IS NULL OR `ExternalURL` = '')
         AND `Visible` = 1 LIMIT 1

SELECT
                MAX(`Monday`) AS `1`,
                MAX(`Tuesday`) AS `2`,
                MAX(`Wednesday`) AS `3`,
                MAX(`Thursday`) AS `4`,
                MAX(`Friday`) AS `5`,
                MAX(`Saturday`) AS `6`,
                MAX(`Sunday`) AS `7`
            FROM
                `projections`
         WHERE `Visible` = 1

SELECT
                *
            FROM
                `projections`
            WHERE
                `Wednesday` != ''
         AND `Visible` = 1 ORDER BY `PostDate` ASC

SELECT
                `pages`.`ID`,
                `pages`.`ParentID`,
                `pages`.`MenuLabel`,
                `pages`.`URLLabel`,
                `pages`.`ExternalURL`,
                `SubPages`.`ID` AS `SubPageID`
            FROM
                `pages`
                LEFT JOIN `pages` AS `SubPages` ON `pages`.`ID` = `SubPages`.`ParentID` AND `SubPages`.`Visible` = 1 WHERE `pages`.`MenuLabel` <> ''  AND `pages`.`Visible` = 1
            GROUP BY
                `pages`.`ID`
            ORDER BY
                `pages`.`ParentID` ASC,
                `pages`.`PostDate` ASC

SELECT
                `pages`.`ID`,
                `pages`.`ParentID`,
                `pages`.`FooterLabel`,
                `pages`.`URLLabel`,
                `pages`.`ExternalURL`,
                `SubPages`.`ID` AS `SubPageID`
            FROM
                `pages`
                LEFT JOIN `pages` AS `SubPages` ON `pages`.`ID` = `SubPages`.`ParentID` AND `SubPages`.`Visible` = 1 WHERE `pages`.`FooterLabel` <> ''  AND `pages`.`Visible` = 1
            GROUP BY
                `pages`.`ID`
            ORDER BY
                `pages`.`ParentID` ASC,
                `pages`.`PostDate` ASC
# [16-Nov-2022 14:37:26] /photonics/www/bg/orders/1.html?dt=202211161030 167.99.142.201

set names utf8

SELECT
                `Label`,
                `Value`
            FROM
                `labels`
            WHERE
                `Module` = 'months'
             ORDER BY
                `labels`.`Label` ASC

SELECT
                *
	        FROM
	        	`projections`
	    	WHERE
	    		`ID` = 1
         AND `Visible` = 1 LIMIT 1

SELECT
                `Label`,
                `Value`
            FROM
                `labels`
            WHERE
                `Module` = 'error'
             ORDER BY
                `labels`.`Label` ASC

SELECT
                `Label`,
                `Value`
            FROM
                `labels`
            WHERE
                `Module` = 'orders'
             ORDER BY
                `labels`.`Label` ASC

SELECT
                `Price`,
                `Price2`,
                `Price3`,
                `Price4`
	        FROM
	        	`projections`
	    	WHERE
	    		`ID` = 1
         AND `Visible` = 1 LIMIT 1

SELECT
                `ID`,
                `Data`
            FROM
                `orders`
            WHERE
                `ClientID` = '1d0b4ad0b6fe7de5393ef5e223f61c7189f0892d08fb550c921600d16694f102' AND
                `Status` <= 1
            LIMIT 1

SELECT
                `URLLabel`
            FROM
                `pages`
            WHERE
                `Module` = 'rules'
         AND `Visible` = 1 LIMIT 1

SELECT
                `Label`,
                `Value`
            FROM
                `labels`
            WHERE
                `Module` = 'terms'
             ORDER BY
                `labels`.`Label` ASC

SELECT
                `pages`.`ID`,
                `pages`.`ParentID`,
                `pages`.`MenuLabel`,
                `pages`.`URLLabel`,
                `pages`.`ExternalURL`,
                `SubPages`.`ID` AS `SubPageID`
            FROM
                `pages`
                LEFT JOIN `pages` AS `SubPages` ON `pages`.`ID` = `SubPages`.`ParentID` AND `SubPages`.`Visible` = 1 WHERE `pages`.`MenuLabel` <> ''  AND `pages`.`Visible` = 1
            GROUP BY
                `pages`.`ID`
            ORDER BY
                `pages`.`ParentID` ASC,
                `pages`.`PostDate` ASC

SELECT
                `pages`.`ID`,
                `pages`.`ParentID`,
                `pages`.`FooterLabel`,
                `pages`.`URLLabel`,
                `pages`.`ExternalURL`,
                `SubPages`.`ID` AS `SubPageID`
            FROM
                `pages`
                LEFT JOIN `pages` AS `SubPages` ON `pages`.`ID` = `SubPages`.`ParentID` AND `SubPages`.`Visible` = 1 WHERE `pages`.`FooterLabel` <> ''  AND `pages`.`Visible` = 1
            GROUP BY
                `pages`.`ID`
            ORDER BY
                `pages`.`ParentID` ASC,
                `pages`.`PostDate` ASC
# [16-Nov-2022 14:43:37] /photonics/www/bg/orders/1.html?dt=202211161030 167.99.142.201

set names utf8

SELECT
                `Label`,
                `Value`
            FROM
                `labels`
            WHERE
                `Module` = 'months'
             ORDER BY
                `labels`.`Label` ASC

SELECT
                *
	        FROM
	        	`projections`
	    	WHERE
	    		`ID` = 1
         AND `Visible` = 1 LIMIT 1

SELECT
                `Label`,
                `Value`
            FROM
                `labels`
            WHERE
                `Module` = 'error'
             ORDER BY
                `labels`.`Label` ASC

SELECT
                `Label`,
                `Value`
            FROM
                `labels`
            WHERE
                `Module` = 'orders'
             ORDER BY
                `labels`.`Label` ASC

SELECT
                `Price`,
                `Price2`,
                `Price3`,
                `Price4`
	        FROM
	        	`projections`
	    	WHERE
	    		`ID` = 1
         AND `Visible` = 1 LIMIT 1

SELECT
                `ID`,
                `Data`
            FROM
                `orders`
            WHERE
                `ClientID` = '1d0b4ad0b6fe7de5393ef5e223f61c7189f0892d08fb550c921600d16694f102' AND
                `Status` <= 1
            LIMIT 1

SELECT
                `URLLabel`
            FROM
                `pages`
            WHERE
                `Module` = 'rules'
         AND `Visible` = 1 LIMIT 1

SELECT
                `Label`,
                `Value`
            FROM
                `labels`
            WHERE
                `Module` = 'terms'
             ORDER BY
                `labels`.`Label` ASC

SELECT
                `pages`.`ID`,
                `pages`.`ParentID`,
                `pages`.`MenuLabel`,
                `pages`.`URLLabel`,
                `pages`.`ExternalURL`,
                `SubPages`.`ID` AS `SubPageID`
            FROM
                `pages`
                LEFT JOIN `pages` AS `SubPages` ON `pages`.`ID` = `SubPages`.`ParentID` AND `SubPages`.`Visible` = 1 WHERE `pages`.`MenuLabel` <> ''  AND `pages`.`Visible` = 1
            GROUP BY
                `pages`.`ID`
            ORDER BY
                `pages`.`ParentID` ASC,
                `pages`.`PostDate` ASC

SELECT
                `pages`.`ID`,
                `pages`.`ParentID`,
                `pages`.`FooterLabel`,
                `pages`.`URLLabel`,
                `pages`.`ExternalURL`,
                `SubPages`.`ID` AS `SubPageID`
            FROM
                `pages`
                LEFT JOIN `pages` AS `SubPages` ON `pages`.`ID` = `SubPages`.`ParentID` AND `SubPages`.`Visible` = 1 WHERE `pages`.`FooterLabel` <> ''  AND `pages`.`Visible` = 1
            GROUP BY
                `pages`.`ID`
            ORDER BY
                `pages`.`ParentID` ASC,
                `pages`.`PostDate` ASC
# [16-Nov-2022 14:43:58] /photonics/www/bg/ajax/orders/submit.html?_=1668602645761 167.99.142.201

set names utf8

SELECT
                `ID`,
                `Data`
            FROM
                `orders`
            WHERE
                `ClientID` = '1d0b4ad0b6fe7de5393ef5e223f61c7189f0892d08fb550c921600d16694f102' AND
                `Status` <= 1
            LIMIT 1

SELECT
                `Label`,
                `Value`
            FROM
                `labels`
            WHERE
                `Module` = 'error'
             ORDER BY
                `labels`.`Label` ASC

SELECT
                    `Sale` + `Reserve` AS `All`
    	        FROM
    	        	`projections`
    	    	WHERE
    	    		`ID` = 1 AND
                    `Visible` = 1
                 LIMIT 1

SELECT
                COUNT(`ID`)
            FROM
                `tickets`
            WHERE
                `DateTime` = 202211161030 AND
                `OrderType` & 1

SELECT * FROM `orders` LIMIT 1

SHOW COLUMNS FROM `orders`

INSERT INTO `orders` SET `LastUpdate` = '2022-11-16 14:43:58', `ClientID` = '1d0b4ad0b6fe7de5393ef5e223f61c7189f0892d08fb550c921600d16694f102', `ProjectionID` = '1', `Data` = '0F9gaIIIJENboqNOh-C5FPYBcCTzReo8LDPvSl5zw_rR9aNMAo_QVHWAtgMPwnJ5XmtPRDccrA4ftA1mFr5zBANP2FwCoVieqmQH9RhBgGA7KME7bAxsGtpZq1K3oEgSPhMjK932MNQoVz9Qe5blbOZgeM_JY91gDI3hNPg88WU7q3yV6_FvUM9yscm7tMHYtM_ZPBv2xCufAT2r7HKI2R-_LUBsj1cX_MVuE7SPC7nvsock6H1DJOxNliYBcXktiYTbc5J7m2UBbhmhxD0Td4Veo5RKkuWnvxZDxS5rBh54CGwqNRCnFf5UHHk0KfFY', `SearchKey` = 'wrvCs8K6w4zDicwrHDhMKywoLCvswrjCtMKuw4LDiMKJwr7DwrnDg8KqwobCv8KJwrbDnMK6wrTDoMOAwqvCwqTDgMKtw4zCssKqwrXDrsKkw4HDgc', `SortName` = '1160101', `PostDate` = '2022-11-16 14:43:58'
# [16-Nov-2022 14:43:58] /photonics/www/bg/orders/preview.html 167.99.142.201

set names utf8

SELECT
                `ID`,
                `Data`
            FROM
                `orders`
            WHERE
                `ClientID` = '1d0b4ad0b6fe7de5393ef5e223f61c7189f0892d08fb550c921600d16694f102' AND
                `Status` <= 1
            LIMIT 1

SELECT
                `Label`,
                `Value`
            FROM
                `labels`
            WHERE
                `Module` = 'months'
             ORDER BY
                `labels`.`Label` ASC

SELECT
                *
	        FROM
	        	`projections`
	    	WHERE
	    		`ID` = 1
         AND `Visible` = 1 LIMIT 1

SELECT
                `Price`,
                `Price2`,
                `Price3`,
                `Price4`
	        FROM
	        	`projections`
	    	WHERE
	    		`ID` = 1
         AND `Visible` = 1 LIMIT 1

SELECT
                `Label`,
                `Value`
            FROM
                `labels`
            WHERE
                `Module` = 'orders'
             ORDER BY
                `labels`.`Label` ASC

SELECT
                `pages`.`ID`,
                `pages`.`ParentID`,
                `pages`.`MenuLabel`,
                `pages`.`URLLabel`,
                `pages`.`ExternalURL`,
                `SubPages`.`ID` AS `SubPageID`
            FROM
                `pages`
                LEFT JOIN `pages` AS `SubPages` ON `pages`.`ID` = `SubPages`.`ParentID` AND `SubPages`.`Visible` = 1 WHERE `pages`.`MenuLabel` <> ''  AND `pages`.`Visible` = 1
            GROUP BY
                `pages`.`ID`
            ORDER BY
                `pages`.`ParentID` ASC,
                `pages`.`PostDate` ASC

SELECT
                `pages`.`ID`,
                `pages`.`ParentID`,
                `pages`.`FooterLabel`,
                `pages`.`URLLabel`,
                `pages`.`ExternalURL`,
                `SubPages`.`ID` AS `SubPageID`
            FROM
                `pages`
                LEFT JOIN `pages` AS `SubPages` ON `pages`.`ID` = `SubPages`.`ParentID` AND `SubPages`.`Visible` = 1 WHERE `pages`.`FooterLabel` <> ''  AND `pages`.`Visible` = 1
            GROUP BY
                `pages`.`ID`
            ORDER BY
                `pages`.`ParentID` ASC,
                `pages`.`PostDate` ASC
# [16-Nov-2022 14:44:09] /photonics/www/bg/ajax/orders/confirm.html?_=1668602655924 167.99.142.201

set names utf8

SELECT
                `ID`,
                `Data`
            FROM
                `orders`
            WHERE
                `ClientID` = '1d0b4ad0b6fe7de5393ef5e223f61c7189f0892d08fb550c921600d16694f102' AND
                `Status` <= 1
            LIMIT 1

SELECT
                `Price`,
                `Price2`,
                `Price3`,
                `Price4`
	        FROM
	        	`projections`
	    	WHERE
	    		`ID` = 1
         AND `Visible` = 1 LIMIT 1

INSERT INTO `tickets`
            (`ID`, `PostDate`, `LastUpdate`, `OrderID`, `DateTime`, `OrderType`, `TicketType`, `Price`, `Status`) VALUES
            (NULL, NOW(), NOW(), 132, 202211161030, 1, 1, 10.00, 0)

INSERT INTO `tickets`
            (`ID`, `PostDate`, `LastUpdate`, `OrderID`, `DateTime`, `OrderType`, `TicketType`, `Price`, `Status`) VALUES
            (NULL, NOW(), NOW(), 132, 202211161030, 1, 3, 7.00, 0)

INSERT INTO `tickets`
            (`ID`, `PostDate`, `LastUpdate`, `OrderID`, `DateTime`, `OrderType`, `TicketType`, `Price`, `Status`) VALUES
            (NULL, NOW(), NOW(), 132, 202211161030, 1, 3, 7.00, 0)

INSERT INTO `tickets`
            (`ID`, `PostDate`, `LastUpdate`, `OrderID`, `DateTime`, `OrderType`, `TicketType`, `Price`, `Status`) VALUES
            (NULL, NOW(), NOW(), 132, 202211161030, 1, 3, 7.00, 0)

UPDATE
                    `orders`
                SET
                    `LastUpdate` = NOW(),
                    `Status` = `Status` | 1
                WHERE
                    `ID` = 132
                LIMIT 1

SELECT
                `ID`,
                `Data`
            FROM
                `orders`
            WHERE
                `ClientID` = '1d0b4ad0b6fe7de5393ef5e223f61c7189f0892d08fb550c921600d16694f102' AND
                `Status` <= 1
            LIMIT 1

SELECT
                `ID`,
                `Data`
            FROM
                `orders`
            WHERE
                `ClientID` = '1d0b4ad0b6fe7de5393ef5e223f61c7189f0892d08fb550c921600d16694f102' AND
                `Status` <= 1
            LIMIT 1

SELECT
                `Label`,
                `Value`
            FROM
                `labels`
            WHERE
                `Module` = 'months'
             ORDER BY
                `labels`.`Label` ASC

SELECT
                *
	        FROM
	        	`projections`
	    	WHERE
	    		`ID` = 1
         AND `Visible` = 1 LIMIT 1

SELECT
                `Title`
	        FROM
	        	`projections`
	    	WHERE
	    		`ID` = 1 AND
                `Visible` = 1
             LIMIT 1

SELECT
                `Price`,
                `Price2`,
                `Price3`,
                `Price4`
	        FROM
	        	`projections`
	    	WHERE
	    		`ID` = 1
         AND `Visible` = 1 LIMIT 1

SELECT
                `Label`,
                `Value`
            FROM
                `labels`
            WHERE
                `Module` = 'orders'
             ORDER BY
                `labels`.`Label` ASC

SELECT
                `tickets`.*
            FROM
                `tickets`
                INNER JOIN `orders` ON `tickets`.`OrderID` = `orders`.`ID`
            WHERE
                `orders`.`ID` = 132 AND
                `orders`.`Status` = 1
            ORDER BY
                `tickets`.`ID` ASC

SELECT
                `Title`
	        FROM
	        	`projections`
	    	WHERE
	    		`ID` = 1 AND
                `Visible` = 1
             LIMIT 1

UPDATE
                    `orders`
                SET
                    `LastUpdate` = NOW(),
                    `Status` = `Status` | 2
                WHERE
                    `ID` = 132
                LIMIT 1

UPDATE
                    `orders`
                SET
                    `LastUpdate` = NOW(),
                    `Status` = `Status` | 4
                WHERE
                    `ID` = 132
                LIMIT 1
# [16-Nov-2022 14:44:18] /photonics/www/bg/orders/success-sale.html 167.99.142.201

set names utf8

SELECT
                `pages`.`ID`,
                `pages`.`ParentID`,
                `pages`.`MenuLabel`,
                `pages`.`URLLabel`,
                `pages`.`ExternalURL`,
                `SubPages`.`ID` AS `SubPageID`
            FROM
                `pages`
                LEFT JOIN `pages` AS `SubPages` ON `pages`.`ID` = `SubPages`.`ParentID` AND `SubPages`.`Visible` = 1 WHERE `pages`.`MenuLabel` <> ''  AND `pages`.`Visible` = 1
            GROUP BY
                `pages`.`ID`
            ORDER BY
                `pages`.`ParentID` ASC,
                `pages`.`PostDate` ASC

SELECT
                `pages`.`ID`,
                `pages`.`ParentID`,
                `pages`.`FooterLabel`,
                `pages`.`URLLabel`,
                `pages`.`ExternalURL`,
                `SubPages`.`ID` AS `SubPageID`
            FROM
                `pages`
                LEFT JOIN `pages` AS `SubPages` ON `pages`.`ID` = `SubPages`.`ParentID` AND `SubPages`.`Visible` = 1 WHERE `pages`.`FooterLabel` <> ''  AND `pages`.`Visible` = 1
            GROUP BY
                `pages`.`ID`
            ORDER BY
                `pages`.`ParentID` ASC,
                `pages`.`PostDate` ASC
# [16-Nov-2022 16:23:03] /photonics/www/bg/купи-билет.html 167.99.142.201

set names utf8

SELECT
                *
	        FROM
	        	`pages`
	    	WHERE
	    		`URLLabel` = 'купи-билет' AND
                (`ExternalURL` IS NULL OR `ExternalURL` = '')
         AND `Visible` = 1 LIMIT 1

SELECT
                MAX(`Monday`) AS `1`,
                MAX(`Tuesday`) AS `2`,
                MAX(`Wednesday`) AS `3`,
                MAX(`Thursday`) AS `4`,
                MAX(`Friday`) AS `5`,
                MAX(`Saturday`) AS `6`,
                MAX(`Sunday`) AS `7`
            FROM
                `projections`
         WHERE `Visible` = 1

SELECT
                *
            FROM
                `projections`
            WHERE
                `Wednesday` != ''
         AND `Visible` = 1 ORDER BY `PostDate` ASC

SELECT
                `pages`.`ID`,
                `pages`.`ParentID`,
                `pages`.`MenuLabel`,
                `pages`.`URLLabel`,
                `pages`.`ExternalURL`,
                `SubPages`.`ID` AS `SubPageID`
            FROM
                `pages`
                LEFT JOIN `pages` AS `SubPages` ON `pages`.`ID` = `SubPages`.`ParentID` AND `SubPages`.`Visible` = 1 WHERE `pages`.`MenuLabel` <> ''  AND `pages`.`Visible` = 1
            GROUP BY
                `pages`.`ID`
            ORDER BY
                `pages`.`ParentID` ASC,
                `pages`.`PostDate` ASC

SELECT
                `pages`.`ID`,
                `pages`.`ParentID`,
                `pages`.`FooterLabel`,
                `pages`.`URLLabel`,
                `pages`.`ExternalURL`,
                `SubPages`.`ID` AS `SubPageID`
            FROM
                `pages`
                LEFT JOIN `pages` AS `SubPages` ON `pages`.`ID` = `SubPages`.`ParentID` AND `SubPages`.`Visible` = 1 WHERE `pages`.`FooterLabel` <> ''  AND `pages`.`Visible` = 1
            GROUP BY
                `pages`.`ID`
            ORDER BY
                `pages`.`ParentID` ASC,
                `pages`.`PostDate` ASC
# [16-Nov-2022 16:23:05] /photonics/www/bg/orders/1.html?dt=202211161030 167.99.142.201

set names utf8

SELECT
                `Label`,
                `Value`
            FROM
                `labels`
            WHERE
                `Module` = 'months'
             ORDER BY
                `labels`.`Label` ASC

SELECT
                *
	        FROM
	        	`projections`
	    	WHERE
	    		`ID` = 1
         AND `Visible` = 1 LIMIT 1

SELECT
                `Label`,
                `Value`
            FROM
                `labels`
            WHERE
                `Module` = 'error'
             ORDER BY
                `labels`.`Label` ASC

SELECT
                `Label`,
                `Value`
            FROM
                `labels`
            WHERE
                `Module` = 'orders'
             ORDER BY
                `labels`.`Label` ASC

SELECT
                `Price`,
                `Price2`,
                `Price3`,
                `Price4`
	        FROM
	        	`projections`
	    	WHERE
	    		`ID` = 1
         AND `Visible` = 1 LIMIT 1

SELECT
                `ID`,
                `Data`
            FROM
                `orders`
            WHERE
                `ClientID` = '1d0b4ad0b6fe7de5393ef5e223f61c7189f0892d08fb550c921600d16694f102' AND
                `Status` <= 1
            LIMIT 1

SELECT
                `URLLabel`
            FROM
                `pages`
            WHERE
                `Module` = 'rules'
         AND `Visible` = 1 LIMIT 1

SELECT
                `Label`,
                `Value`
            FROM
                `labels`
            WHERE
                `Module` = 'terms'
             ORDER BY
                `labels`.`Label` ASC

SELECT
                `pages`.`ID`,
                `pages`.`ParentID`,
                `pages`.`MenuLabel`,
                `pages`.`URLLabel`,
                `pages`.`ExternalURL`,
                `SubPages`.`ID` AS `SubPageID`
            FROM
                `pages`
                LEFT JOIN `pages` AS `SubPages` ON `pages`.`ID` = `SubPages`.`ParentID` AND `SubPages`.`Visible` = 1 WHERE `pages`.`MenuLabel` <> ''  AND `pages`.`Visible` = 1
            GROUP BY
                `pages`.`ID`
            ORDER BY
                `pages`.`ParentID` ASC,
                `pages`.`PostDate` ASC

SELECT
                `pages`.`ID`,
                `pages`.`ParentID`,
                `pages`.`FooterLabel`,
                `pages`.`URLLabel`,
                `pages`.`ExternalURL`,
                `SubPages`.`ID` AS `SubPageID`
            FROM
                `pages`
                LEFT JOIN `pages` AS `SubPages` ON `pages`.`ID` = `SubPages`.`ParentID` AND `SubPages`.`Visible` = 1 WHERE `pages`.`FooterLabel` <> ''  AND `pages`.`Visible` = 1
            GROUP BY
                `pages`.`ID`
            ORDER BY
                `pages`.`ParentID` ASC,
                `pages`.`PostDate` ASC
