Home > Archive > MySQL ODBC Connector > September 2005 > Limiting "DISTINCT" To One Column









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Limiting "DISTINCT" To One Column
Hal Vaughan

2005-09-29, 11:23 am

I have a query like this:

SELECT DISTINCT Channel, ChannelType, Source FROM ChannelStatus;

Each channel is supposedly listed in this table only 1 time, but just in case,
what I really want to do is make sure that no channels are duplicated. Is
there some way to make the keyword "DISTINCT" apply to Channel only? Sort of
a shortcut to (example in pseudocode, although it'd be in Perl):

SELECT DISTINCT Channel FROM ChannelStatus;
FOR EACH Channel
SELECT Channel, ChannelType FROM Source WHERE Channel = 'channel'
ENDLOOP

Thanks!

Hal

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql? unsub...sie.nctu.edu.tw

Hank

2005-09-29, 1:23 pm

To check for more than one channel-per-record in the table:

select channel,count(*) as cnt from ChannelStatus group by channel having c=
nt>1

should return zero records if you have no dups.


On 9/29/05, Hal Vaughan < hal@thresholddigital
.com> wrote:
> I have a query like this:
>
> SELECT DISTINCT Channel, ChannelType, Source FROM ChannelStatus;
>
> Each channel is supposedly listed in this table only 1 time, but just in =

case,

> what I really want to do is make sure that no channels are duplicated. I=

s
> there some way to make the keyword "DISTINCT" apply to Channel only? Sor=

t of
> a shortcut to (example in pseudocode, although it'd be in Perl):
>
> SELECT DISTINCT Channel FROM ChannelStatus;
> FOR EACH Channel
> SELECT Channel, ChannelType FROM Source WHERE Channel =3D 'channel=

'
> ENDLOOP
>
> Thanks!
>
> Hal
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql? unsub...mail
.com

>
>



--

-Hank

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql? unsub...sie.nctu.edu.tw

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com