SELECT delivery_method, agency_id, address_id
FROM basket_defaults
SELECT v.code delivery_method, o.date_send, o.agency_id, o.address_id
FROM basket o
JOIN vn2008.Vistas v ON o.delivery_method_id = v.vista_id
CALL agency_list_from_date (#date, #address);
SELECT a.Id_Agencia, a.description
FROM t_agency t
JOIN vn2008.Agencias a ON a.Id_Agencia = t.agency_id
JOIN vn2008.Vistas v ON a.Vista = v.vista_id
WHERE a.web != FALSE
AND v.code = 'AGENCY'
ORDER BY a.description;
DROP TEMPORARY TABLE t_agency;
CALL agency_list_from_date (#date, #address);
SELECT a.Id_Agencia, SUBSTR(a.description, 5) description
FROM t_agency t
JOIN vn2008.Agencias a ON a.Id_Agencia = t.agency_id
JOIN vn2008.Vistas v ON a.Vista = v.vista_id
WHERE a.web != FALSE
AND v.code = 'PICKUP'
ORDER BY a.description;
DROP TEMPORARY TABLE t_agency;