NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Selecting Just 1 Of Duplicates

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
5 members in live chat ~  


Reply
 
LinkBack Thread Tools
Old 09-11-2010, 04:18 PM THREAD STARTER               #1 (permalink)
NamePros Regular
Join Date: Jun 2005
Posts: 518
boomers has a spectacular aura aboutboomers has a spectacular aura about
 



Selecting Just 1 Of Duplicates


I've an SQL select statement that I use to display some records within a DataList. Within my database there are duplicate records (not in error, they are supposed to be there), but instead of these duplicates showing in the Datalist for every record; I want just one to be shown.



Records in database:
ID Names
1 John
2 Sean
3 Michael
4 John
5 William

Required selected:
John
????: NamePros.com http://www.namepros.com/programming/676787-selecting-just-1-of-duplicates.html
Sean
Michael
William



Does anyone know who to achieve this?

---------- Post added at 11:18 PM ---------- Previous post was at 10:06 PM ----------

I've found the 'distinct' statement but cant get it to only use one column for the duplicates...

Records in database:
ID Names
1 John 18
2 Sean 18
3 Michael 19
4 John 18
5 William 21

Required selected:
John 18
Sean 18
Michael 19
William 21
__________________
Free Horse Racing Tips
boomers is offline   Reply With Quote
Old 09-12-2010, 06:25 PM   #2 (permalink)
NamePros Regular
 
baxter's Avatar
Join Date: Apr 2006
Posts: 360
baxter is just really nicebaxter is just really nicebaxter is just really nicebaxter is just really nice
 


Ethan Allen Fund Save The Children
Group by will work for you

Code:
SELECT * FROM (TABLE) GROUP BY names
__________________
Canadian Domain Registrar Ready.ca
baxter is offline   Reply With Quote
Old 09-15-2010, 07:43 PM   #3 (permalink)
NamePros Member
Join Date: Nov 2003
Location: Ontario, Canada
Posts: 127
eagle12 will become famous soon enougheagle12 will become famous soon enough
 



To use distinct you need to have exactly the same info returned. When you do a select *, it is including you id. If you just wrote:

select distinct Names from table;

that would return what you are looking for.
eagle12 is offline   Reply With Quote
Old 09-15-2010, 10:12 PM   #4 (permalink)
Senior Member
 
defaultuser's Avatar
Join Date: May 2009
Location: internet@ctivist.com
Posts: 4,790
defaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatness
 



Select help from google where searchterm = sql
__________________
A Member of: IdeationTeam.com
HowToBeADomainer.com - a Domaining How To
AuthorEditor.com
defaultuser is online now   Reply With Quote
Old 09-16-2010, 07:17 PM   #5 (permalink)
NamePros Member
Join Date: Nov 2003
Location: Ontario, Canada
Posts: 127
eagle12 will become famous soon enougheagle12 will become famous soon enough
 



That's helpful. Arrogant people like you are the problem with forums like this.
eagle12 is offline   Reply With Quote
Old 09-16-2010, 09:25 PM   #6 (permalink)
Senior Member
 
defaultuser's Avatar
Join Date: May 2009
Location: internet@ctivist.com
Posts: 4,790
defaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatness
 



Originally Posted by eagle12 View Post
That's helpful. Arrogant people like you are the problem with forums like this.
Actually I was just trying to be cute. If the answer had not already been stated then I would have provided it to you. I'm actually not a jerk.
????: NamePros.com http://www.namepros.com/showthread.php?t=676787

The GROUP BY will work just fine - the DISTINCT won't work as you found out. A distinct is just a specialized form of group (done by all selected columns) - I find this just confuses people.

I'm not sure why you think there's a problem with forums like this. You posted your question - you got an answer. Sounds like it is working fairly well to me.

I apologize for offending you. Please lighten up!
__________________
A Member of: IdeationTeam.com
HowToBeADomainer.com - a Domaining How To
AuthorEditor.com
defaultuser is online now   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 02:37 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger