code: func getHostnameForNIC(c context.Context, q database.QueryerContext, name, machine string) (*int64, error) {
  	rows, err := q.QueryContext(c, `
  		SELECT h.id FROM nics n, machines m, hostnames h
  		WHERE n.machine_id = m.id AND n.hostname_id = h.id AND n.name = ? AND m.name = ?
  	`, name, machine)
  	if err != nil {
  		return nil, errors.Annotate(err, "failed to fetch associated hostname").Err()
  	}
  	defer rows.Close()
  	if rows.Next() {
  		var hostnameId int64
  		if err = rows.Scan(&hostnameId); err != nil {
  			return nil, errors.Annotate(err, "failed to fetch hostname").Err()
  		}
  		return &hostnameId, nil
  	}
  	return nil, nil
  }
docs: // getHostnameForNIC gets the ID of the hostname associated with an existing NIC.