Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 5th, 2003, 04:40 PM
area area is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Ohio
Posts: 27 area User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 23 m 40 sec
Reputation Power: 0
Send a message via ICQ to area Send a message via AIM to area
Filtering out duplicate values

I'm filtering a large table.. one of the fields is filtered by the expression: <>"" AND <>"NA" it works fine, but now I need to filter that same field so that it doesnt include any values that repeat.. what do i need to add to the expression to do this?

Thanks,
Alan

Reply With Quote
  #2  
Old November 6th, 2003, 05:36 PM
shammat shammat is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 987 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 1 h 23 m 13 sec
Reputation Power: 57
I'm not sure I understand what you want. You want all rows exclude where values in that specific column occur more then once?

This should work (not tested)

SELECT *
FROM table
WHERE col1 <> ""
AND col1 <> "NA"
AND col1 NOT IN
(SELECT col1
FROM table1
GROUP BY col1
HAVING count(*) > 1);

But this will remove any row where the content of col1 exists more then once (it will not even return one of those rows)

Reply With Quote
  #3  
Old November 14th, 2003, 08:56 PM
alam alam is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 67 alam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 17 sec
Reputation Power: 5
use "Not Exist" instead of "Not In" to avoid full table scan.
(if shammat's code is working)

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Filtering out duplicate values


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway