Re: Re: MySQL - Selecting Unique Entries
| From: | Sheridan Saint-Michel | Date: | Wed, 03 Oct 2001 18:23:51 +0000 |
| Subject: | Re: Re: MySQL - Selecting Unique Entries | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-69807@lists.php.net to get a copy of this message | ||
Distinct is just a group by on all columns, so either of the queries
you showed should be pretty much the same. The difference
between the two shows up when you have multiple columns in
your select. ie
Select distinct id,name from table1;
and
Select id,name from table1 group by name;
do two different things. The first will combine only those rows who
has the same value in both id and name, the second will combine any
rows with the same value in name.
Sheridan Saint-Michel
Website Administrator
FoxJet, an ITW Company
www.foxjet.com
"Tom Churm" <thomas.churm@pixelpark.com> wrote in message
news:3BB46D2D.2475A55F@pixelpark.com...
> hi,
>
> i need to weed out all duplicate entries in a select statement.
> i've done research and have discovered 2 different possible solutions
> for this. i'd like to know which one is better to use?
>
> after trying them out on MySQL, Select Distinct appears to be highly
> unreliable. i get somewhat better results when i use Select Distinct
> trim(seminar_name), but this Group By solution seems to work better:
>
> SELECT seminar_name
> FROM student_table GROUP BY seminar_name
>
> SELECT DISTINCT seminar_name
> FROM student_table
>
> thanks for the advice,
>
> tom