salix/db/routines/hedera/procedures/myTicket_getPackages.sql

21 lines
573 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myTicket_getPackages`(vSelf INT)
BEGIN
/**
* Returns a current user ticket packages.
*
* @param vSelf The ticket identifier
* @select The ticket packages
*/
SELECT i.image, im.updated, i.id, i.name, tp.quantity
FROM myTicket t
JOIN vn.ticketPackaging tp ON tp.ticketFk = t.id
JOIN vn.packaging p ON p.id = tp.packagingFk
JOIN vn.item i ON i.id = p.itemFk
LEFT JOIN image im
ON im.collectionFk = 'catalog'
AND im.name = i.image
WHERE t.id = vSelf;
END$$
DELIMITER ;