mysql query show multiple tables from one ID column

后端 未结 3 1070
青春惊慌失措
青春惊慌失措 2020-12-22 12:53

I\'m trying to find this query where I want to show which hosts uses which template from my Zabbix table. The only problem is that hosts and templates are registered in the

3条回答
  •  借酒劲吻你
    2020-12-22 13:40

    This is a basic question. You should learn more about SQL syntax, such as chained joins, accessing same column name from different tables.

    Example code:

    select h1.name, h2.name
    from hosts_templates ht
        inner join hosts h1 on ht.hostid = h1.hostid
        inner join hosts h2 on ht.templateid = h2.hostid;
    

提交回复
热议问题