# fleet

Shiji Zhou

04/15/2023, 2:29 AM
@Kathy Satterlee Thanks. In the
method in
, there is a SQL query to get label queries for given host :
Copy code
query := `SELECT id, query FROM labels WHERE platform = ? OR platform = '' AND label_membership_type = ?`
	rows, err = ds.reader.QueryContext(ctx, query, platform, fleet.LabelMembershipTypeDynamic)
Considering that MySQL
operator takes precedence over the
operator, the query is the same as:
Copy code
SELECT id, query FROM labels WHERE platform = ? OR (platform = '' AND label_membership_type = ?);
With this statement, a label query will be returned if the host's platform matches label's platform, even if the label's label_membership_type is
instead of
. However, a "manual" label is populated manually without the execution of a label query, so it is meaningless to return label queries for a manual label. Then I would suppose the query should look like:
Copy code
`SELECT id, query FROM labels WHERE (platform = ? OR platform = '') AND label_membership_type = ?`
Which instead means that it only gets
label queries if the label's platform matches the host's or the label's platform is "all platforms" I really appreciate it if someone could correct my misunderstandings, or confirm that there are some problems here.🤝

Kathy Satterlee

04/15/2023, 7:25 PM
Since manual labels don’t have a platform field, the query works as structured. It will grab queries for labels that are either for the correct platform, or that don’t have a platform specified and are dynamic labels

Shiji Zhou

04/16/2023, 6:26 PM
I see,thank you very much 👍