I have a query that returns a small number of rows (usually 2-5) but a huge number of columns (several hundred). The rows are mostly identical, save for a few places. I would like to quickly identify them by hiding columns which are constant (e.g., I have 5 products, all of which cost $ 3, so the cost column should be suppressed). Is there an elegant way to do this using MySQL? If it helps, most of the columns are numerical.
Here’s a tiny example: Suppose my initial query returns
col1|col2|col3|col4 1 | x | a | 3.14 1 | x | b | 3.14
Columns 1, 2 and 4 are “constant”, while column 3 is not. Therefore I would like a secondary query to return only column 3:
|col3| | a | | b |
The problem is that manually finding a small number of non-constant columns is quite difficult with a large number of constant columns.