Ами просто:
SELECT
SUM(IF(name = ?, 1, 0)) AS name_count,
SUM(IF(address = ? AND port = ?, 1, 0)) AS addr_count
FROM
table_name
Ами просто:
SELECT
SUM(IF(name = ?, 1, 0)) AS name_count,
SUM(IF(address = ? AND port = ?, 1, 0)) AS addr_count
FROM
table_name