reduce output from database to exclude duplications.

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Sculpture
Forum Commoner
Posts: 41
Joined: Sat Jun 11, 2005 6:57 pm
Location: Australia
Contact:

reduce output from database to exclude duplications.

Post by Sculpture »

Hello all,

I am trying to figure out a way to restrict a query to excude duplications. There is a table that supplies 2 dropdown tables, one for suburbs and another field for postcodes. The administrator can insert new suburbs and postcodes but sometimes several of the suburbs have the same postcodes. Therefore, needless to say, the postcode dropdown ends up with extraneous postcodes.

Code: Select all

mysql_select_db($database_connect_form, $connect_form);
$query_qArea = "SELECT town, postcode FROM areas";
$qArea = mysql_query($query_qArea, $connect_form) or die(mysql_error());
$row_qArea = mysql_fetch_assoc($qArea);
$totalRows_qArea = mysql_num_rows($qArea);
This is the query, I was wondering if there is a formula that I could use with the select statement that would select unique entries.

Thanks
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

distinct()
User avatar
Sculpture
Forum Commoner
Posts: 41
Joined: Sat Jun 11, 2005 6:57 pm
Location: Australia
Contact:

Post by Sculpture »

Thank you hawleyjr, works a treat. :D
Post Reply