Re: MySQL - Selecting Unique Entries

From: Date: Wed, 03 Oct 2001 16:21:15 +0000
Subject: Re: MySQL - Selecting Unique Entries
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-69794@lists.php.net to get a copy of this message
Tom: if you need to weed out duplicates you may try knowing which entries duplicate themselves and how many times they are duplicated, why don't you try. SELECT seminar_name COUNT(*) FROM student_table GROUP BY seminar_name This will return the seminar_name field plus a COUNT field that will display the number of times the first field was found. If you want the seminar_name to be unique and not be repeated then you should get "1" in every row of the COUNT field, the rows that get more than "1" are repeated and this way you will know which ones to eliminate. Later. Iván Milanez "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

« previous php.general (#69794) next »