 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
SteveW Guest
|
Posted: Wed May 02, 2007 5:12 pm Post subject: MYSQL query to eliminate duplicates |
|
|
I need to select all records from a table but exclude any duplicates.
eg Table Tickets Field "reg" contains:
ticket No Reg
1 xy123
2 xy123
3 ab123
4 bc123
5 bc123
I need to return
ticket No Reg
1 xy123
3 ab123
4 bc123
Cheers
SteveW |
|
| Back to top |
|
 |
Vassiliev V. V. Guest
|
Posted: Wed May 02, 2007 6:36 pm Post subject: Re: MYSQL query to eliminate duplicates |
|
|
In your example you have no duplicates in ticketNo column. For what you need
select min(ticketNo) as ticketNo, Reg
from Tickets
group by Reg
should work for most DBMS. To get only Reg
select distinct Reg from Tickets
should work.
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"SteveW" <Stevewarby (AT) btinternet (DOT) com> сообщил/сообщила в новостях следующее:
news:46388039 (AT) newsgroups (DOT) borland.com...
| Quote: | I need to select all records from a table but exclude any duplicates.
eg Table Tickets Field "reg" contains:
ticket No Reg
1 xy123
2 xy123
3 ab123
4 bc123
5 bc123
I need to return
ticket No Reg
1 xy123
3 ab123
4 bc123
Cheers
SteveW
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|