I am confused. What is the model. is a table? should'n b and c be the
same table?
I think you mean

db.define_table('team',db.Field('name'))
db.define_table('match',db.Field('t1',db.team),db.Field('t2',db.team))
a=db.team.with_alias('a')
b=db.team.with_alias('b')
rows=db().select(db.match.ALL,a.name,b.name,left=[a.on
(a.id==db.match.t1),b.on(b.id==db.match.t2)])
for row in rows: print row.a,row.b

This generates:

SELECT match.id, match.t1, match.t2, a.name, b.name FROM match LEFT
JOIN team AS a ON a.id=match.t1 LEFT JOIN team AS b ON b.id=match.t2;

Beat that SQLAlchemy!

Massimo

On Dec 10, 9:48 pm, DenesL <[EMAIL PROTECTED]> wrote:
> billf, that works using db.executesql().
> I wonder what is the DAL equivalent.
>
> On Dec 10, 6:15 pm, billf <[EMAIL PROTECTED]> wrote:
>
> > in sql:
>
> > select * from matches a inner join teams b on a.team1_id=b.teams_id
> > inner join teams c on a.team2_id=c.team_id
>
> > so that a.? is match data, b.? is team1 data and c.? is team2 data
>
> > On Dec 10, 10:47 pm, pedro <[EMAIL PROTECTED]> wrote:
>
> > > On 10 Dec, 23:35, DenesL <[EMAIL PROTECTED]> wrote:
>
> > > > > SELECT * FROM teams, matches WHERE matches.team1_id=teams.id AND
> > > > > matches.team2_id=teams.id
>
> > > > If I interpret that correctly it means: look for all matches where a
> > > > team played itself.
> > > > Unless you are looking for wrongly entered match info it would not be
> > > > very useful.
>
> > > After looking carefully to my query I came to that conclusion too.
> > > _select() returns exactly the SQL statement I initially thought,
> > > problem is that was incorrect. That is indeed not useful at all.
> > > So this turns out to be a question about basic SQL,
> > > How do I  select all matches, from the matches table, and the teams'
> > > names from the teams table?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to