SELECT io.ref, t.id AS ticketFk FROM invoiceOut io JOIN ticket t ON t.refFk = io.ref JOIN client c ON c.id = io.clientFk WHERE io.id = ?