The following query will retrieve the sub-domain name, ftp username, and ftp password for a specific domain.
SELECT CONCAT(CONCAT(s.name, '.'), d.name) AS subdomain, u.login, a.password FROM subdomains AS s JOIN domains AS d ON s.dom_id=d.id JOIN sys_users AS u ON s.sys_user_id=u.id JOIN accounts AS a ON u.account_id=a.id WHERE d.name='example.com'
If you want to see all subdomains, then omit the WHERE clause.