Quote:
Originally Posted by floristboy
This does exactly what I require - takes out three fields from the 'Links' table where the 'site' field is unique.
|
sorry, but i have a feeling you don't understand how DISTINCT works
DISTINCT is ~not~ a function, and it applies to
all columns in the SELECT clause
you wrote it with parentheses around the first column, thinking that the "distinctness" would be applied to that column...
SELECT DISTINCT (
site), location, locationlink
however, in actual fact the "distinctness" applies to all columns...
SELECT DISTINCT
(site), location, locationlink
furthermore, you have a GROUP BY clause confounding the issue
GROUP BY site ensures that there is exactly one result row per site, but since the other two columns in your SELECT clause are omitted from the GROUP BY clause (i.e. "hidden" from the GROUP BY clause), the values for those columns are indeterminate
see
MySQL :: MySQL 5.1 Reference Manual :: 11.12.3 GROUP BY and HAVING with Hidden Columns