Thanks! Based on your suggestion, I tried the following:
The inner query goes like this:
repetition_table_2 = repetition_table.alias()
s_inner = select([repetition_table_2.c.card_key],
(repetition_table_2.c.rep_number==5) \
(repetition_table_2.c.grade==2)).limit(10)
:55:56 AM
Subject: [sqlalchemy] Re: Advice on complicated (?) SQL query
Thanks! Based on your suggestion, I tried the following:
The inner query goes like this:
repetition_table_2 = repetition_table.alias()
s_inner = select([repetition_table_2.c.card_key],
(repetition_table_2
Barry Hart wrote:
Try this for the outer query:
s =
select([repetition_table.c.grade],(repetition_table.c.rep_number==2)
(repetition_table.c.card_key.in_(s_inner)) )
Great, that did the trick!
Thanks,
Peter
--~--~-~--~~~---~--~~
You received this
I think you want the final SQL query to look something like this:
select * from
card_table
join repetition_table on repetition_table.card_key = card_table.id
where repetition_table.rep_number = 1 and repetition_table.rep_number = 4 and
card_table.id in
(select ct2.id from card_table AS ct2