mysql distinct row or distinct field
distinct, mysql
Solution
There is no such thing as "distinct field". Your first syntax is parsed identically to the second: the parentheses merely surround a field expression. You could also write:
SELECT DISTINCT (users.id), (2) AS someFieldName, (0) AS someOtherFieldName
They are all equivalent.
If you want to avoid comparisons on your constant columns, you could instead use `GROUP BY`:
SELECT users.id, 2 AS someFieldName, 0 AS someOtherFieldName
FROM users JOIN ...
GROUP BY users.id
Problem
Is there a performance or other difference between this: ``` SELECT distinct(users.id),2 as someFieldName ,0 as someOtherFieldName From users join ... ``` and this: ``` SELECT distinct users.id ,2 as someFieldName ,0 as someOtherFieldName From users join ... ``` result set is used as part of an insert statement and the select might return the same user i.d multiple time due to the join (not displayed here) I am using mysql.