Re: Struggling with qualifiers involving sets
Re: Struggling with qualifiers involving sets
- Subject: Re: Struggling with qualifiers involving sets
- From: Jonathan Rochkind <email@hidden>
- Date: Mon, 04 Aug 2003 10:06:40 -0500
It may not be a major pain, but it's not quite the same thing. It takes two
trips to the db, and depending on your db and how it functions, it might
end up being a lot slower than the one-query version. For a database with
a large population, where the subquery returns thousands of rows, the
two-query version might not even work----some databases have a maximum
number of terms you can have in the "WHERE" clause.
When "IN" is used with a straight list of literals ( "IN (1,2,3)"), it's
exactly identical to just using "OR", indeed. When the "IN" is used with a
subquery though ("IN (SELECT ... )"), it's a somewhat different thing. But
I don't even know if the ERXInQualifier lets you do subqueries. I believe
there is something in the Wonder stuff that lets you do subqueries. There's
no way to do subquerries with the built-in EOQualifiers, although you can
hack it with raw SQL and the EOSQLQualifier.
Subquerries (and "IN" is just one way to use sub-querries, there are others
that will do other things that you couldn't do with an "OR") are in my
opinion often very useful. I think that formally there's nothing you can do
with a sub-query that you can't do with an outer join. But it's a pain to
use outer joins in EOF too---none of your relationships generally ought to
be defined as outer joins, yet you sometimes want to use an outer join in a
query. And it's sometimes conceptually easier (for me at least) to write a
sub-query than to write an outer join that does what you want.
--Jonathan
At 06:04 PM 8/3/2003 -1000, Art Isbell wrote:
On Sunday, August 3, 2003, at 05:52 PM, Arturo Pirez wrote:
Not always. What about
select a from b where col in (select c from d where col2 = e)
If that subselect returns more than a few dozen things then ORing is
going to be a major
pain.
Not really.
How would you address the above?
Iterate over the subselect result set creating an EOQualifier for
each "c" value. Add each qualifier to an array. Use the array as an
argument to an EOOrQualifier. I wouldn't consider this to be a major pain.
And can you do it without using something from
Project Wonder? :)
Sure (see above).
Aloha,
Art
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.