[TransWarp] Towards a query theory, part 6: building queries from filters

alexander smishlajev alex at ank-sia.com
Fri Oct 17 04:55:40 EDT 2003


Phillip J. Eby wrote, at 17.10.2003 5:29:

> Rather than using EXISTS(SELECT ...) for subqueries, we will use 
> IN(SELECT ...).  This appears to be enormously easier to do correctly.

are you sure that IN may substitute EXISTS?  here's an example:

  select * from table1 x where exists
   (select * from table2 y where y.a = x.a and y.b = x.b)

> * We've ignored compound keys and ternary (or higher-arity) 
> relationships in discussion so far.  Our main use cases may not include 
> these as a requirement, though.  Compound keys can't cleanly be used for 
> IN (SELECT ...) subqueries.

ah, well, the above example looks like compound key.  ok, another example:

  select x.*, y.* from table1 x, table2 y
   where x.a = y.a and exists
    (select * from table3 z where z.b = x.b and z.c = y.c)

best wishes,
alex.






More information about the PEAK mailing list