[SQL] avoid duplicates when using SELECT

Last update on September 5, 2009 09:28 AM by jak58
Published by jak58

[SQL] avoid duplicates when using SELECT







Issue

How to avoid duplicates in the results of a SQL query?
Solution

Simply use the DISTINCT clause and between the SELECT clause and the fields.
Example:

SELECT distinct id,name,surname FROM mytable


More informations available on this page:
http://dev.mysql.com/doc/refman/5.0/en/select.html
Best answers for « avoid duplicates when using SELECT » in :
Avoid duplicates in Excel Show Avoid duplicates in Excel In order to avoid duplication when encoding in a column from an excel sheet: take the conditional format on the first cell under the headings (eg A2) choose the following formula:...
Delete duplicates in an Excel column Show Delete duplicates in an Excel column To remove duplicates in an Excel column: Click on the Data menu Filter Advanced Filter In this menu, select the column where the duplicates Check the box "Extract without duplication"...
[MySQL]Delete duplicates in a table Show [MySQL]Delete duplicates in a table To remove duplicates in a table set up as follows: CREATE TABLE IF NOT EXISTS TabTest ( prim_key integer(4) NOT NULL auto_increment, x integer, y integer, ...
DUPLICATE ENTRY '127' FOR KEY 1 ShowDUPLICATE ENTRY '127' FOR KEY 1 If you are using MySQL and you are facing the error “duplicate entry ‘127’ for key 1” while trying to make an entry in your database table, do not panic. This should be linked to the following and can easily...
MySQL - SELECT ... YESTERDAY ShowMySQL - SELECT ... YESTERDAY Make use of the following syntax: SELECT * FROM myTable WHERE field_date = DATE_SUB(CONCAT(CURDATE(), ' 00:00:00'), INTERVAL 1 DAY) In order to select previous records: SELECT * FROM myTable WHERE field_date =...
Vi/Vim - Avoid tabs when making a copy/paste Show[VI/VIM] Avoid tabs when making a copy/paste By default, when you make a copy and paste in vi or vim (through an remote SSH session), it adds incremented tabs at each line. To solve this problem,simply type: set paste in the window or add the...
Download Duplicates Remover for Outlook ShowRemove Duplicates for Outlook allows you to remove duplicate messages that appear in Microsoft Outlook Express. Advantage It lets you search for duplicate messages from the last time. It also allows you to delete, copy, duplicate and in a...
ATA, IDE and EIDE ShowOverview The ATA (Advanced Technology Attachment) standard is a standard interface that allows you to connect storage peripherals to PC computers. The ATA standard was developed on May 12, 1994 by the ANSI (document X3.221-1994). Despite the...
HTML forms ShowForms Interactive forms let web page authors give their pages interactive elements, such as for receiving messages from their readers, much like the reply cards found in some magazines. The reader enters information by filling in fields or clicking...
Hardware Interrupts (IRQ) and Conflicts ShowThe Concept of Interrupts Because the processor cannot simultaneously process several pieces of information (it processes one piece of information at a time), a program being run can, thanks to an interrupt request, be momentarily suspended while...