Ad Widget

Collapse

Help with database query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alj
    Senior Member
    • Aug 2006
    • 188

    #1

    Help with database query

    I cant find documentation for 1.4 database schema and its not obvious to me how to do this just by looking at the table descriptions, but can somebody help me with the query that will extract list of host which have certain template associated to them? Thanks!
  • Calimero
    Senior Member
    • Nov 2006
    • 481

    #2
    Maybe you could try this:

    Code:
    SELECT h.hostid, h.host, t.host AS template_name
    FROM hosts_templates AS h_tpl
    JOIN hosts AS h ON h.hostid = h_tpl.hostid
    JOIN hosts AS t ON t.hostid = h_tpl.templateid AND t.status = 3
    WHERE t.host = '<tpl name>'

    Comment

    • alj
      Senior Member
      • Aug 2006
      • 188

      #3
      Originally posted by Calimero
      Maybe you could try this:

      Code:
      SELECT h.hostid, h.host, t.host AS template_name
      FROM hosts_templates AS h_tpl
      JOIN hosts AS h ON h.hostid = h_tpl.hostid
      JOIN hosts AS t ON t.hostid = h_tpl.templateid AND t.status = 3
      WHERE t.host = '<tpl name>'
      THganks, works great.

      Comment

      Working...