No but if you join the same table multiple times
(db.researcher_lab_permission) you have to do so using an alias. This
should work.
groups = db().select(db.groups.name,db.city.name
,db.auth_user.email,db.researcher.with_alias('name1').ALL, db.lab.
with_alias('name2').ALL,
join=[db.groups.on(db.groups.id ==
db.lab.group_id),
db.city.on(db.city.id == db.groups.city_id),
db.auth_user.on(db.researcher.user_id ==
db.auth_user.id),
db.researcher.with_alias('name1').on(
db.researcher.id == db.researcher_lab_permission.researcher_id),
db.lab.with_alias('name2').on(db.lab.id ==
db.researcher_lab_permission.lab_id)
])
You would have the same issue with raw SQL.
On Monday, 28 October 2013 15:29:02 UTC-5, Diogo Munaro wrote:
>
> Hey guys, I'm using web2py with mysql and I can't do a Inner Join
>
> When I try:
>
> groups = db().select(db.groups.name,db.city.name,
> join=[db.groups.on(db.groups.id ==
> db.lab.group_id),
> db.city.on(db.city.id ==
> db.groups.city_id),
> db.auth_user.on(db.researcher.user_id ==
> db.auth_user.id),
> db.researcher.on(db.researcher.id ==
> db.researcher_lab_permission.researcher_id),
> db.lab.on(db.lab.id ==
> db.researcher_lab_permission.lab_id)
> ])
>
>
> Raise this error:
>
> <class 'gluon.contrib.pymysql.err.InternalError'> (1054, u"Unknown column
> 'lab.group_id' in 'on clause'")
>
>
> But when I try only:
>
> groups = db().select(db.groups.name,db.city.name,
> join=[db.groups.on(db.groups.id ==
> db.lab.group_id),
> db.city.on(db.city.id == db.groups.city_id)
> ])
>
>
> It's works. There are some limit for tables join?
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.