SELECT c.id, c.socialName, c.street AS postalAddress, IF (ios.taxAreaFk IS NOT NULL, CONCAT(cty.code, c.fi), c.fi) fi, CONCAT(c.postcode, ' - ', c.city) postcodeCity FROM vn.invoiceOut io JOIN vn.client c ON c.id = io.clientFk JOIN vn.country cty ON cty.id = c.countryFk LEFT JOIN vn.invoiceOutSerial ios ON ios.code = io.serial AND ios.taxAreaFk = 'CEE' WHERE io.id = ?