Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old December 30th, 2002, 04:22 PM
Beano Beano is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Stirling, Scotland
Posts: 3 Beano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
finding duplicates

I'm looking for some help with something pretty basic here and was wondering if anyone could maybe help me.

I have a transactions table - horse racing tips - that holds amongst other things, a number of values, each of which is the primary key to another table e.g. it holds the primary key ids for jockeys, courses etc. on a lookup basis. I'm trying to find out which one occurs the most number of times and also which one occurs the least so that I can display some basis stats for visitors.

So for example, if the horse with ID number 26 has been selected 10 times and horse number 22 has been selected 12 times and horse number 1 has been selected only once, I'd like to be able to show that the top selection is number 22 with 12 selections and the bottom selection number 1 with 1 selection. I'm sure there must be some quick and easy way to do this rather than having to sit and cut a whole lot of clumsy code.

Anyone any ideas?

I hope this makes sense!


Reply With Quote
  #2  
Old December 30th, 2002, 05:26 PM
hermawan's Avatar
hermawan hermawan is offline
Superman is not dead
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Jakarta, Indonesia
Posts: 553 hermawan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 26 m 38 sec
Reputation Power: 2
Send a message via ICQ to hermawan Send a message via AIM to hermawan Send a message via Yahoo to hermawan Send a message via Google Talk to hermawan Send a message via Skype to hermawan
RE: finding duplicates

make the selected_times as an alias, then ORDER BY that alias. Sample:

SELECT *, selected_time as sel_time FROM table WHERE field=condition GROUP BY horse_id ORDER BY sel_time

Reply With Quote
  #3  
Old December 31st, 2002, 08:43 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: finding duplicates

Thanks. I've gone for the following

SELECT pid, count(*) as sel_time FROM todaystip WHERE outcome = "won" GROUP BY pid ORDER BY sel_time DESC;

which gives me a list of the number of selections in descending order which is just what I'm looking for.

Thanks again for your help

Reply With Quote
  #4  
Old September 8th, 2003, 01:18 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: finding duplicates

How would one find duplicates in a mysql database in the field "email" then export a comma delimited de-duped list ?

Reply With Quote
  #5  
Old September 8th, 2003, 04:02 PM
honcho's Avatar
honcho honcho is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Cape Cod
Posts: 1,347 honcho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 2 sec
Reputation Power: 3
RE: RE: finding duplicates

Quote:
How would one find duplicates in a mysql database in the field "email" then export a comma delimited de-duped list ?


You can just select all distinct email addresses, then there is no de-duping:

SELECT DISTINCT email FROM table_name

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > finding duplicates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT