Constructing proper attribute query syntax