Mysql: how to get unique values in column that can have a value or 0
Try this:

SELECT * FROM mytable WHERE C=0 
UNION ALL
SELECT * FROM mytable WHERE C&lt;&gt;0 GROUP BY C;


The caveat here is that you have no control on which row will be returned from each set of rows that have the same values of "C"

mysql&gt; desc mytable;
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| a     | int(11) | YES  |     | NULL    |       |
| b     | int(11) | YES  |     | NULL    |       |
| c     | int(11) | YES  |     | NULL    |       |
+-------+---------+------+-----+---------+-------+
3 rows in set (0.01 sec)

mysql&gt; select * from mytable;
+------+------+------+
| a    | b    | c    |
+------+------+------+
|    0 |    1 |    4 |
|    4 |    5 |    6 |
|    6 |    5 |    0 |
|    5 |    6 |    0 |
|    7 |    5 |    4 |
|    8 |    5 |    6 |
|    9 |    5 |    0 |
+------+------+------+
7 rows in set (0.00 sec)

mysql&gt; SELECT * FROM mytable WHERE C=0 
    -&gt; UNION ALL
    -&gt; SELECT * FROM mytable WHERE C&lt;&gt;0 GROUP BY C;
+------+------+------+
| a    | b    | c    |
+------+------+------+
|    6 |    5 |    0 |
|    5 |    6 |    0 |
|    9 |    5 |    0 |
|    0 |    1 |    4 |
|    4 |    5 |    6 |
+------+------+------+
5 rows in set (0.00 sec)