Unix Technical Forum

How to do a select on a column with no repeats

This is a discussion on How to do a select on a column with no repeats within the MySQL forums, part of the Database Server Software category; --> Hello all, I'm needing to do a select on a certain column of a database and have the results ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 09:50 AM
Bryan
 
Posts: n/a
Default How to do a select on a column with no repeats

Hello all,

I'm needing to do a select on a certain column of a database and have
the results returned with no repeats. For example, say I have a table
of addresses and one of the columns is the state. I have 5 entries in
the table and three of them are in the state of Texas. When I do a
select for the state from the table I want it to only return Texas as a
result only once instead of three times.

Is this possible? Thanks!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 09:50 AM
Bryan
 
Posts: n/a
Default Re: How to do a select on a column with no repeats

Oops... I bet I can get what I want if I use the DISTINCT keyword
huh...

On Dec 28, 8:51 pm, "Bryan" <BTRichard...@gmail.com> wrote:
> Hello all,
>
> I'm needing to do a select on a certain column of a database and have
> the results returned with no repeats. For example, say I have a table
> of addresses and one of the columns is the state. I have 5 entries in
> the table and three of them are in the state of Texas. When I do a
> select for the state from the table I want it to only return Texas as a
> result only once instead of three times.
>
> Is this possible? Thanks!


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 09:50 AM
Jerry Stuckle
 
Posts: n/a
Default Re: How to do a select on a column with no repeats

Bryan wrote:
> Hello all,
>
> I'm needing to do a select on a certain column of a database and have
> the results returned with no repeats. For example, say I have a table
> of addresses and one of the columns is the state. I have 5 entries in
> the table and three of them are in the state of Texas. When I do a
> select for the state from the table I want it to only return Texas as a
> result only once instead of three times.
>
> Is this possible? Thanks!
>


http://dev.mysql.com/doc/refman/5.1/en/select.html

See the DISTINCT keyword.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 09:51 AM
Bryan
 
Posts: n/a
Default Re: How to do a select on a column with no repeats

Is it possible to do an SQL query on a result set from a previous SQL
query?

On Dec 28, 8:54 pm, "Bryan" <BTRichard...@gmail.com> wrote:
> Oops... I bet I can get what I want if I use the DISTINCT keyword
> huh...
>
> On Dec 28, 8:51 pm, "Bryan" <BTRichard...@gmail.com> wrote:
>
>
>
> > Hello all,

>
> > I'm needing to do a select on a certain column of a database and have
> > the results returned with no repeats. For example, say I have a table
> > of addresses and one of the columns is the state. I have 5 entries in
> > the table and three of them are in the state of Texas. When I do a
> > select for the state from the table I want it to only return Texas as a
> > result only once instead of three times.

>
> > Is this possible? Thanks!- Hide quoted text -- Show quoted text -


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-28-2008, 09:51 AM
strawberry
 
Posts: n/a
Default Re: How to do a select on a column with no repeats


Bryan wrote:
> Is it possible to do an SQL query on a result set from a previous SQL
> query?
>
> On Dec 28, 8:54 pm, "Bryan" <BTRichard...@gmail.com> wrote:
> > Oops... I bet I can get what I want if I use the DISTINCT keyword
> > huh...
> >
> > On Dec 28, 8:51 pm, "Bryan" <BTRichard...@gmail.com> wrote:
> >
> >
> >
> > > Hello all,

> >
> > > I'm needing to do a select on a certain column of a database and have
> > > the results returned with no repeats. For example, say I have a table
> > > of addresses and one of the columns is the state. I have 5 entries in
> > > the table and three of them are in the state of Texas. When I do a
> > > select for the state from the table I want it to only return Texas as a
> > > result only once instead of three times.

> >
> > > Is this possible? Thanks!- Hide quoted text -- Show quoted text -


Yes (see VIEWS), however I'm sure a brief skim through the manual
would answer all these questions. You might even discover how to do the
entire query with just one statement (see sub-queries and/or JOINS).

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:16 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com