tags:

views:

26

answers:

2

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.

A: 

That sounds like very strange behavior, but why don't you try this:

select distinct sid from board
Fosco
A: 

ACK. PEBKAC, sorry. Thanks for all the help. I didn't realize I had it nested in another loop and so the distinct resultset was actually echoing out multiple times.

Eric