sql,query

Hi List

Please can someone help me with this:

I need to "filter" duplicate entries from my result query, but there's a
twist...

The table has something like this:

id      name    key
1       name1   key1
2       name2   key2
3       name3   key3
4       name1   key1
5       name 1  key1
6       name2   key2


Now I want to search the table for all unique name/key combinations.

I tried 
select DISTINCTROW name,key from table order by name;

but, it returns
name1   key1
name2   key2
name3   key3
name 1  key1

Where name 1 key1 was obviously a typo, yet, I would ideally want to
filter or flag this through some kind of logic => ( there is already a
key1 associated with a name1, cannot associate key1 with another name!)

Firstly, my problem is with the query as I quoted it itself, ie, is that
the best way to prevent duplicates? I might also try this:

select DISTINCTROW MAX(id),name,key from table group by name;
but this will only ensure that only the LATEST key/name "pair" is listed
right?

Second, how do I translate my "logic" above into SQL? Or should I do it
in PHP?

Thanks.



 






---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to