Domanda

I have the following issue. We have two tables that look like that :

[t1]
Ruler   ID1 S1  E1
**1     a   1   10**
1       b   17  24
1       c   20  24
1       d   21  24
*2      e   40  47*    

[t2]
Ruler   ID2 S2  E2
**1     a   7   15**
**1     b   8   16**
2       c   25  35
*2      d   41  50*

[t3]
Ruler   ID1 S1  E1  ID2  S2  E2  
**1     a    1  10    a   7  15
1       a    1  10    b   8  16**
*2      e   40   7    d  41  50*
  • We have about 20 scales (here I just show scale 1 and 2)
  • S1 (S2) AND E1(E2) Represent respectively start and end position on a scale
  • L1(L2) is the length of each segment. Segment from t1 can overlap
  • segments from t2 and vice-versa Multiple segments can overlap each other

To select segments that overlap each other I need to do a CROSS JOIN of t1 and t2 and find what segment from t2 overlap those in t1 and then insert those into t3.

If I do table UPDATE that returns 0 match rows

UPDATE t3 CROSS JOIN (t1, t2) ON 
  ((t2.S2 BETWEEN t1.S1 AND t1.E1) OR (t2.E2 BETWEEN t1.S1 AND t1.E1))
SET t3.CHR1 = t1.CHR1, t3.ID1 = t1.ID1, t3.S1 = t1.S1, t3.E1 = t1.E1, t3.ID2 =
t2.ID2, t3.S2 = t2.S2, t3.E2 = t2.E2
WHERE t1.CHR1 = t2.CHR2;

If I do INSERT INTO t3 ( or a INNER JOIN) that doesn't replace a CROSS JOIN. ...So I don't know what to do from here..

È stato utile?

Soluzione

I Believe your query syntax is wrong.

update command syntax was update <table> set x=(select query),... where ...

And more over here it looks like you are joining T3 in the process and trying to update the temp table (t3 CROSS JOIN (t1, t2)) created in the join command.

Please check the syntax of cross join also.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top