I have a simple table called "board" that has a column called "sid" - that is just integers. Many of these are duplicates. I want to know only distinct values in this column, so I do this:
SELECT sid FROM board GROUP BY sid
When I run this query directly in phpMyAdmin, I get the set I was expecting. No problem. However, this bit of code returns every row in the entire table, without exception:
$sql = "SELECT sid FROM board GROUP BY sid"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ echo $row["sid"] . "<br />"; }
Does anyone know why? FYI I've tried every combination of DISTINCT and GROUP BY I could think of, but no matter what I do, I can't get a distinct set to echo out.