The use of \'distinct\' is actually usefull when selecting a field from a table, but where that field can contain the same value over the entire table (not all field, but some).
When using \'distinct\' in a \'select\', you will only get one result, instead of all matching results (assuming you only select 1 field off course).
So in your example, the \'distinct\' applies to all field you request. In that way, you won\'t get duplicated results. If that is what you want: it\'s the correct syntax.
For your second question, you can use different approaches.
1) Sort the result on the \'name\', and use a sort of $current_name ; $pervious_name mechanism in your code to separate the different \'names\'.
2) Use 2 SQL queries instead of one.
3) erm ... there are more, but I cannot get them out of my mind :wink:
Hope this helps,
Grtz,
Toni.