dbTalk Databases Forums  

eliminate duplicate in JOIN

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss eliminate duplicate in JOIN in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Carl Forsman
 
Posts: n/a

Default eliminate duplicate in JOIN - 04-05-2009 , 03:39 AM






The following query will return Triple word from a table like the
following:

pretty, woman, a
a, pretty woman
china,great, wall
wall, great, china
great, wall, china

=============================
How can I elimate rows that contain the same words?
The output should be:

pretty, woman, a
wall, great, china
-OR-
a, pretty woman
wall, great, china
-OR-
a, pretty woman
great, wall, china

.... etc

=============================
The output should not have 2 row containsexact 3 words

For example, if I have 3 words ( pretty + woman + a )
pretty, woman, a

Then the output will not contain (a + pretty + woman)
a, pretty woman

=============================
SELECT DISTINCT A.word As word1, B.word AS word2, C.word AS word3
FROM Data AS A
JOIN Data AS B
ON A.document = B.document
AND A.position < B.position
AND ABS(A.position - B.position) < 3
JOIN Data AS C
ON A.document = C.document
AND A.position < C.position
AND B.position < C.position
AND ABS(A.position - C.position) < 3
ORDER BY word1;


Reply With Quote
  #2  
Old   
Shakespeare
 
Posts: n/a

Default Re: eliminate duplicate in JOIN - 04-05-2009 , 03:40 AM






Carl Forsman schreef:
Quote:
The following query will return Triple word from a table like the
following:

pretty, woman, a
a, pretty woman
china,great, wall
wall, great, china
great, wall, china

=============================
How can I elimate rows that contain the same words?
The output should be:

pretty, woman, a
wall, great, china
-OR-
a, pretty woman
wall, great, china
-OR-
a, pretty woman
great, wall, china

... etc

=============================
The output should not have 2 row containsexact 3 words

For example, if I have 3 words ( pretty + woman + a )
pretty, woman, a

Then the output will not contain (a + pretty + woman)
a, pretty woman

=============================
SELECT DISTINCT A.word As word1, B.word AS word2, C.word AS word3
FROM Data AS A
JOIN Data AS B
ON A.document = B.document
AND A.position < B.position
AND ABS(A.position - B.position) < 3
JOIN Data AS C
ON A.document = C.document
AND A.position < C.position
AND B.position < C.position
AND ABS(A.position - C.position) < 3
ORDER BY word1;

By only accepting sequences that are in alphabetic order, but then you
may have to circumvent duplicate words.

Shakespeare


Reply With Quote
  #3  
Old   
Carl Forsman
 
Posts: n/a

Default Re: eliminate duplicate in JOIN - 04-05-2009 , 04:52 AM



On Sun, 05 Apr 2009 10:40:27 +0200, Shakespeare <whatsin (AT) xs4all (DOT) nl>
wrote:

Quote:
Carl Forsman schreef:
The following query will return Triple word from a table like the
following:

pretty, woman, a
a, pretty woman
china,great, wall
wall, great, china
great, wall, china

=============================
How can I elimate rows that contain the same words?
The output should be:

pretty, woman, a
wall, great, china
-OR-
a, pretty woman
wall, great, china
-OR-
a, pretty woman
great, wall, china

... etc

=============================
The output should not have 2 row containsexact 3 words

For example, if I have 3 words ( pretty + woman + a )
pretty, woman, a

Then the output will not contain (a + pretty + woman)
a, pretty woman

=============================
SELECT DISTINCT A.word As word1, B.word AS word2, C.word AS word3
FROM Data AS A
JOIN Data AS B
ON A.document = B.document
AND A.position < B.position
AND ABS(A.position - B.position) < 3
JOIN Data AS C
ON A.document = C.document
AND A.position < C.position
AND B.position < C.position
AND ABS(A.position - C.position) < 3
ORDER BY word1;


By only accepting sequences that are in alphabetic order, but then you
may have to circumvent duplicate words.

Shakespeare
thanks for the advice!

but how to do it in the above query?

or what command to use?


Reply With Quote
  #4  
Old   
Michael Austin
 
Posts: n/a

Default Re: eliminate duplicate in JOIN - 04-05-2009 , 12:52 PM



Carl Forsman wrote:
Quote:
On Sun, 05 Apr 2009 10:40:27 +0200, Shakespeare <whatsin (AT) xs4all (DOT) nl
wrote:

Carl Forsman schreef:
The following query will return Triple word from a table like the
following:

pretty, woman, a
a, pretty woman
china,great, wall
wall, great, china
great, wall, china

=============================
How can I elimate rows that contain the same words?
The output should be:

pretty, woman, a
wall, great, china
-OR-
a, pretty woman
wall, great, china
-OR-
a, pretty woman
great, wall, china

... etc

=============================
The output should not have 2 row containsexact 3 words

For example, if I have 3 words ( pretty + woman + a )
pretty, woman, a

Then the output will not contain (a + pretty + woman)
a, pretty woman

=============================
SELECT DISTINCT A.word As word1, B.word AS word2, C.word AS word3
FROM Data AS A
JOIN Data AS B
ON A.document = B.document
AND A.position < B.position
AND ABS(A.position - B.position) < 3
JOIN Data AS C
ON A.document = C.document
AND A.position < C.position
AND B.position < C.position
AND ABS(A.position - C.position) < 3
ORDER BY word1;

By only accepting sequences that are in alphabetic order, but then you
may have to circumvent duplicate words.

Shakespeare
thanks for the advice!

but how to do it in the above query?

or what command to use?

First do not MULTI-POST - use CROSS-POST (learn the difference)- I think
you hit every db NG you could find...

As stated in another NG - fix your design so you do not have this
problem by having a unique doc_id in this table so one and only one
entry exist so you never have this problem.


Reply With Quote
  #5  
Old   
Shakespeare
 
Posts: n/a

Default Re: eliminate duplicate in JOIN - 04-06-2009 , 01:28 PM



Carl Forsman schreef:
Quote:
On Sun, 05 Apr 2009 10:40:27 +0200, Shakespeare <whatsin (AT) xs4all (DOT) nl
wrote:

Carl Forsman schreef:
The following query will return Triple word from a table like the
following:

pretty, woman, a
a, pretty woman
china,great, wall
wall, great, china
great, wall, china

=============================
How can I elimate rows that contain the same words?
The output should be:

pretty, woman, a
wall, great, china
-OR-
a, pretty woman
wall, great, china
-OR-
a, pretty woman
great, wall, china

... etc

=============================
The output should not have 2 row containsexact 3 words

For example, if I have 3 words ( pretty + woman + a )
pretty, woman, a

Then the output will not contain (a + pretty + woman)
a, pretty woman

=============================
SELECT DISTINCT A.word As word1, B.word AS word2, C.word AS word3
FROM Data AS A
JOIN Data AS B
ON A.document = B.document
AND A.position < B.position
AND ABS(A.position - B.position) < 3
JOIN Data AS C
ON A.document = C.document
AND A.position < C.position
AND B.position < C.position
AND ABS(A.position - C.position) < 3
ORDER BY word1;

By only accepting sequences that are in alphabetic order, but then you
may have to circumvent duplicate words.

Shakespeare
thanks for the advice!

but how to do it in the above query?

or what command to use?
<your select>
and word1 < word2 and word2 < word3


?


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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.