salix/print/templates/reports/invoice/sql/tickets.sql

16 lines
396 B
SQL

SELECT
t.id,
t.shipped,
t.nickname,
tto.description,
t.addressFk,
a.street
FROM invoiceOut io
JOIN ticket t ON t.refFk = io.REF
JOIN `address` a ON a.id = t.addressFk
LEFT JOIN observationType ot ON ot.code = 'invoiceOut'
LEFT JOIN ticketObservation tto ON tto.ticketFk = t.id
AND tto.observationTypeFk = ot.id
WHERE t.refFk = ?
ORDER BY t.shipped