Wednesday, 23 May 2012
 Home arrow Blog arrow Ignore duplicate entries in MySQL select using DISTINCT keyword
   
Main Menu
Home
News
Blog
Links
Search
FAQs
Spider
Articles
@intrenet
Free Softwares
Break for fun
Friends VIdeos
Techno videos
Contact Us
Disclaimer
Guest Book
Speed test
V.E.C. Calculator
IPv4 Subnet Calc
IPv6 Subnet Calc
Byte Converter
Converter
GMT/UTC Time
Bandwidth Calc
Allinone Calc
IANA Port Numbers
Country Call Codes
Pk Postal Codes
Surf Anonumously
Visitors Counter
mod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_counter
mod_vvisit_counterToday199
mod_vvisit_counterYesterday260
mod_vvisit_counterThis week459
mod_vvisit_counterThis month5008
mod_vvisit_counterAll125684
 
 
 
 


Ignore duplicate entries in MySQL select using DISTINCT keyword PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Amanatullah khalil   
Sunday, 24 May 2009

Ignore duplicate entries in MySQL select using DISTINCT keyword

 

Sometimes every occurance of a value which may be duplicated multiple times in a result set is not needed. For example, if making a pulldown menu list of options, each option should be seen only once. The DISTINCT keyword in a select statement eliminates duplication in the result set.


The column party from the presidents sample table has many repeats in it. To select a list of the parties from the table, use:

SELECT DISTINCT party FROM presidents;

This returns a result set that looks like:

+-----------------------+
| party |
+-----------------------+
| no party |
| Federalist |
| Democratic-Republican |
| Democratic |
| Whig |
| Republican |
+-----------------------+

Using the DISTINCT keyword on queries with multiple columns will return unique combinations of values on all of the columns. For example, the query

SELECT DISTINCT givenname, party FROM presidents;

returns 36 out of a possible 43 rows. Each row is a unique combination of first name and political party.

 courtesy http://www.tech-recipes.com/rx/1481/ignore-duplicate-entries-in-mysql-select-using-distinct-keyword/

 
< Prev   Next >
 
 
 
csatpk Newsflash
Statistics
OS: Linux h
PHP: 5.2.17
MySQL: 5.1.63-community-log
Time: 03:48
Caching: Disabled
GZIP: Disabled
Members: 3
News: 368
Web Links: 5
Visitors: 266030
Popular