yes and no.
this NO
thisq = db(db.keyword.keyword == 'this')._select(db.keyword.question)
result = db(db.question.id.belongs(thisq)).select(db.question.ALL)
but this YES
thisq = [r.question for r in db(db.keyword.keyword ==
'this').select(db.keyword.question)]
result = db(db.question.id.belongs
Please disregard last question - nested select does seem to work using
the same chaining technique:
thisq = db(db.keyword.keyword == 'this')._select(db.keyword.question)
thatq = db(db.keyword.keyword == 'that')
(db.keyword.belongs(thisq))._select(db.keyword.question)
result = db(db.question.id.bel
On Apr 11, 7:40 pm, Paul Wray wrote:
> Thank you Massimo
>
> I didnt know about the chained queries like this ie db(q1)(q2) .
> Is this feature documented in the book?
yes db()() is the same as db(()&())
> I like how this allows a neat construction for n keywords:
>
> q = db()
> for k in keyw
Sorry, try this
db(db.question.id == db.keyword.id)(db.keyword.keyword ==
'this')(db.keyword.keyword == 'that').select()
-Thadeus
On Sun, Apr 11, 2010 at 7:46 PM, Thadeus Burgess wrote:
> Does the following provide the results that you are looking for?
>
> db(db.question.id > 0)(db.keyword
Does the following provide the results that you are looking for?
db(db.question.id > 0)(db.keyword.keyword ==
'this')(db.keyword.keyword == 'that').select()
-Thadeus
On Sat, Apr 10, 2010 at 9:36 AM, mdipierro wrote:
> I would do
>
> db(db.question.id.belongs(db(db.keyword.keyword=='this')).
Thank you Massimo
I didnt know about the chained queries like this ie db(q1)(q2) .
Is this feature documented in the book?
I like how this allows a neat construction for n keywords:
q = db()
for k in keywords:
q = q(db.question.id.belongs(db(db.keyword.keyword =
k).select(db.qkeyword.questi
Thank you Massimo
I didnt know about the chained queries like this ie db(q1)(q2) .
Is this feature documented in the book?
I like how this allows a neat construction for n keywords:
q = db()
for k in keywords:
q = q(db.question.id.belongs(db(db.keyword.keyword =
k).select(db.qkeyword.questi
I would do
db(db.question.id.belongs(db(db.keyword.keyword=='this'))._select(db.keyword.question))
(db.question.id.belongs(db(db.keyword.keyword=='that'))._select(db.keyword.question)).select(db.problem.ALL)
It will be faster.
On Apr 10, 8:31 am, Paul Wray wrote:
> Thanks for your reply
>
> The
Thanks for your reply
The SQL I wish to produce is:
'SELECT question.* FROM question, keyword as k2, keyword as k1 WHERE
((k1.keyword="this") AND (k2.keyword="that") AND
(k1.question=k2.question) AND (k1.question=question.id))'
That is, find all questions that have both the keyword 'this' and the
Inner joins in DAL do not support AS. Can you show an SQL example of
how you would use it?
Massimo
On Apr 8, 10:08 pm, Paul Wray wrote:
> Hello
>
> I'm attempting a simple self join and having trouble with the aliases.
> The slightly simplified query is:
>
> k1 = db.qkeyword.with_alias('k1')
> k
10 matches
Mail list logo