Mariadb multiple choice from dashboard variable

Hello, i have a mariadb query

SELECT clock * 1000 as time, value AS "$host ping" 
FROM history_uint 
WHERE itemid = (
    SELECT i.itemid
    FROM items i
    JOIN hosts h ON i.hostid = h.hostid
    WHERE i.name = 'ICMP: ICMP ping' AND h.host LIKE CONCAT('%', (SELECT(REGEXP_SUBSTR($host, '\\d+-\\d+.*'))), '%')
)
AND clock >= ROUND(${__from}/1000)
AND clock <= ROUND(${__to}/1000)
/*ORDER BY clock DESC LIMIT 1;*/

It’s works ok when i chose one variable. I want to use multiply options to show different hosts on one graph. How can i do this?

how would you do such a query outside of grafana?