On Wed, Mar 15, 2006 at 05:47:52PM +0100, Sybren St?vel wrote:
> select z.id
Well, you know SQLObject really does "SELECT * FROM zone"...
> from zone z
> left join subzone s on(z.id = s.zone_id)
> where s.id in (
> select s.id from subzone s
> left join registered_user r on(
> s.start_x <= r.location_x and
> s.end_x >= r.location_x and
> s.start_y <= r.location_y and
> s.end_y >= r.location_y and
> s.start_z <= r.location_z and
> s.end_z >= r.location_z)
> group by s.id
> having count(r.id) > 0
> )
Let split it into simpler parts.
select *
from zone z
left join subzone s on(z.id = s.zone_id)
where s.id in (ids)
class Zone(SQLObject):
name = StringCol()
class Subzone(SQLObject):
zone = ForeignKey("Zone")
print Zone.select(
IN(Subzone.q.id, [1, 2, 3]),
join=LEFTJOINOn(None, Subzone, Subzone.q.zoneID == Zone.q.id)
)
Prints
SELECT zone.id, zone.name FROM zone LEFT JOIN subzone ON (subzone.zone_id =
zone.id) WHERE (subzone.id IN (1, 2, 3))
Good?
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED]
Programmers don't die, they just GOSUB without RETURN.
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss