SELECT id, invoiceInFk, taxableBase, expenseFk, taxTypeSageFk, transactionTypeSageFk, foreignValue FROM invoiceInTax iit JOIN transactionTypeSage ts ON iit.transactionTypeSageFk = ts.id JOIN taxTypeSage tts ON tts.id = WHERE io.ref = ? ORDER BY iot.id