Hi, I have problem running this query. It will time out for me...

My database are small just about 200 members.

I have a site for swaping appartments (rental). my query should look

for match

in a triangle. Like this member A -> B->C

A give his appartment to B. B gives his appartment to C and finally

C gives his appartment to A

Soo my query looks for matching parameters like rooms, location, size

and

soo on..

I have one table for existing appartments and one for "whanted

appartments"

and 1 table called "intresse" where members can store "yes" or "no" if

they are interessted in a appartment.

I also have a table called "omrade" to store locations of interest.

Hope you can helpe me with some tip soo i can run this query in a few

seconds instead of 20-30 sec

Thanks M

SELECT

F.medlemsNr as medlemsNr, F.lfId AS lfId, F.ort AS ort, F.gatuadress

AS gatuadress, F.gatuNr AS gatuNr, F.rum AS rum,F.storlek AS

storlek,

F.hyra AS hyra, count(F.medlems Nr) As hits

FROM

medlem08 A, medlem08 B, medlem08 C, lagenhetF08 D,

lagenhetO08 E, lagenhetF08 F, lagenhetO08 G, lagenhetF08 H,

lagenhetO08 I

WHERE

D.rum >= I.rumMin AND D.rum <= I.rumMax AND

D.storlek >= I.storlekMin AND D.storlek <= I.storlekMax AND

I.hyraMax = 0" & " OR D.hyra <= I.hyraMax) AND

I.balkong = '" & "" & "' OR D.balkong = I.balkong) AND

(I.badkar = '" & "" & "' OR D.badkar = I.badkar) AND

(I.bredband = '" & "" & "' OR D.bredband = I.bredband) AND

(I.hiss = '" & "" & "' OR D.hiss = I.hiss) AND

(I.spis = '" & "" & "' OR D.spis = I.spis) AND

(I.brf = '" & "" & "' OR D.brf = I.brf) AND

D.postNr IN (select postNr from ONSKEMAL08 where loId=I.loId) AND

F.medlemsNr Not IN (select medlemsNr2 from INTRESSE08 where

medlemsNr1=A.me dlemsNr) AND

H.rum >= G.rumMin AND H.rum <= G.rumMax AND

H.storlek >= G.storlekMin AND H.storlek <= G.storlekMax AND

(G.hyraMax = 0" & " OR H.hyra <= G.hyraMax) AND

(G.balkong = '" & "" & "' OR H.balkong = G.balkong) AND

(G.badkar = '" & "" & "' OR H.badkar = G.badkar) AND

(G.bredband = '" & "" & "' OR H.bredband = G.bredband) AND

(G.spis = '" & "" & "' OR H.spis = G.spis) AND

(G.brf = '" & "" & "' OR H.brf = G.brf) AND

H.postNr IN (select postNr from ONSKEMAL08 where loId=G.loId) AND

F.rum >= E.rumMin AND F.rum <= E.rumMax AND

F.storlek >= E.storlekMin AND F.storlek <= E.storlekMax AND

(E.hyraMax = 0" & " OR F.hyra <= E.hyraMax) AND

(E.balkong = '" & "" & "' OR F.balkong = E.balkong) AND

(E.badkar = '" & "" & "' OR F.badkar = E.badkar) AND

(E.bredband = '" & "" & "' OR F.bredband = E.bredband) AND

(E.hiss = '" & "" & "' OR F.hiss = E.hiss) AND

(E.spis = '" & "" & "' OR F.spis = E.spis) AND

(E.brf = '" & "" & "' OR F.brf = E.brf) AND

F.postNr IN (select postNr from ONSKEMAL08 where loId=E.loId) AND

A.medlemsNr=D.m edlemsNr AND A.medlemsNr=E.m edlemsNr AND

B.medlemsNr<>A. medlemsNr AND C.medlemsNr<>A. medlemsNr AND

B.medlemsNr<>C. medlemsNr AND

B.sparr<>1 AND C.sparr<>1 AND

A.typ=11 AND A.medlemsNr=" & session("medlem sNr") & " AND

B.medlemsNr=F.m edlemsNr AND B.medlemsNr=G.m edlemsNr AND

B.typ=11 AND A.triangel=1 AND B.triangel=1 AND C.triangel=1 AND " &_

C.medlemsNr=H.m edlemsNr AND C.medlemsNr=I.m edlemsNr AND

C.typ=11 group by F.lfId, F.medlemsNr,F.o rt,

F.gatuadress,F. gatuNr,F.rum,F. storlek,F.hyra