Select individual columns

A request in the system I support returns

QID AID DATA 1 2 x 1 2 y 5 6 t 

In accordance with the new requirement, I do not want to repeat the pair (QID, AID) = (1,2). We also do not care what value is selected from the "data" column. either x or y.

I did to enclose an initial query like this

 SELECT * FROM (<original query text>) Results group by QID,AID 

Is there a better way to do this? The original request uses several unions and unions, and what not, so I would prefer not to touch it if it is absolutely necessary

+4
source share
1 answer

If you are not interested in which DATA will be selected, GROUP BY will be nice, although the use of ungrouped and non-aggregated columns in the SELECT the GROUP BY is MySQL specific and not portable.

+2
source

Source: https://habr.com/ru/post/1308000/


All Articles