[EMAIL PROTECTED] wrote:
> Hi Phil
> 
> I am not a SQL guru but the code below should do the trick I think:
> 
> select F1, F2, F3 
> from T1
> where F1 between minValue and maxValue
> and F2 between minValue and maxValue
> and F3 between minValue and maxValue
> 

The values of F1, F2 and F3 are not necessarily sequential. "where F1 in
(x,y,z)" works for F1 but I then need to select F2 and F3 based on the
values of F2 and F3 in the _matched_ rows based on the other conditions.
I don't know the specific values within the sql statement, or at least I
can't come up with a way of specifying the values for F2 and F3 based on
previously _matched_ rows.

I've tried something like

select F1, F2, F3 from T1 as t where F1 in (1,2) or F2 in (select F2
from T1 where T1.F2=t.F2) or F3 in (select F3 from T1 where T1.F3=t.F3)

But this doesn't work. At first I thought it did, but I now have a data
set that doesn't. I believe this is because the subquery is comparing to
each row of T1 as it trawls through the table, not to each row of the
matched set so far.

As I said, I am pretty convinced recursion is the only way. Just making
sure there is no magic scheme out there along the lines of retrieving
hierarchical data based on nested set storage (left and right values):

http://dev.mysql.com/tech-resources/articles/hierarchical-data.html

Fil
_______________________________________________
coders mailing list
coders@slug.org.au
http://lists.slug.org.au/listinfo/coders

Reply via email to