SELECT DISTINCT products.*
FROM products LEFT JOIN prices ON (products.id = prices.product_id)
WHERE prices.region = 'DE'
LIMIT 1, 1
I guess I'm wondering why require_objects isn't sufficient. IOW, is the
DISTINCT part important or is it the fact that only columns from products
are actually fetched?
Okay, the query was too simple. You can only have one 1:N via
require_objects.
SELECT DISTINCT products.*
FROM products LEFT JOIN prices ON (products.id = prices.product_id)
LEFT JOIN prices2 ON (products.id = prices2.product_id)
WHERE prices.region = 'DE'
AND prices2.type = 'resale'
And this for arbitrary complex joins (both 1:N or 1:1, maybe N:M).
I don't want to fetch the subobjects (prices, prices2), I just want to
search in them.
Currently RDBO allows only one table/relation via require_objects. In my
application I would need one 1:N and a prefetch (via
with_objects/require_objects). Right now I can leave the prefetch out,
but if the query ever gets complexer (more 1:N relation to be searched)
I'm out.
The DISTINCT is to avoid double objects, if an product has two prices in
a region 'DE' (maybe for this "shop topic" this is not possible, but for
other topics it is possible).
I would like to distinct between "search joins" and "fetch joins".
A workaround is doing the query by sql only getting the IDs and then
load the objects. But I would like to RDBO entirely for this.
Thanks,
bye Uwe
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object