How can I use "UNION" method to join the while select statement together

I am a new user in AX2012, I am using while select to select my result. Also I would like to use union to join the two while select statement together. I try to use “UnionType::Union”, but it can’t work with while select. Please tell me how can I do that.

Union is supported by the query framework, not by selects in X++. Therefore design your query, then create a QueryRun instance for it and iterate it with QueryRun’s next() method.