Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2004, 08:12 PM
Registered User
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Selecting once where there are many

Hello,

I've seen the answer to this somewhere but have searched my head off. If I am selecting entries from a table, but there are multiple occurances of the same entry (such as "apple" being stored 5 times in a table), how do I select the repetitive entries only once?

Such as:
"select name from table where id = 1" results in:
"Apple, apple, apple, pear, grape, apple"
When what I want is:
"Apple, pear, grape"

Hope that's clear, and thank you!

 
Old March 25th, 2004, 06:22 AM
Authorized User
 
Join Date: Sep 2003
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Let me get this right, you are after only ONE occurence of apple, ONE occurrence of pear, etc?

If that is the case use the DISTINCT key word
Code:
SELECT DISTINCT name FROM table WHERE id =1;
hth

---
David Thorne, Student
UK





Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting MAX Value nirmal_s19 SQL Server ASP 1 May 8th, 2007 01:04 AM
help in selecting elements spandit XSLT 1 April 9th, 2007 07:27 PM
Selecting elements up until a certain one Frode XSLT 5 January 19th, 2006 01:22 PM
Selecting attributs Ma7T XSLT 2 August 5th, 2005 04:21 AM
Selecting Data.. NitinJoshi General .NET 3 January 18th, 2005 02:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.