SELECT co.code
FROM warehouse w
JOIN address a ON a.id = w.addressFk
JOIN client c ON c.id = a.clientFk
JOIN company co ON co.clientFk = c.id
WHERE w.id = ?