The database view trick would work. Or how about adding a "current" flag and
whenever you do a situation update/insert you set the new record's current flag
to true and those of all that person's other situation records to false. You
could either do it in web2py or with a database trigger. Seems
You could create a view of the table "Situation" which groups by id_person
and returns max(id_status). Then you can do a normal join using the view
to establish the relationship between the other two tables.
You can have a view in web2py by creating the table as normal, but marking
it as migra
Yes I have id_situation field but do not know the sub query.
The idea is to catch the last id_sutation person in a subquery
In SQL I managed to make fast
SELECT DISTINCT ON (p.name) p.name, (SELECT s.id_status from situation
where s.id_person = p.id order by id desc limit 1) as status from per
3 matches
Mail list logo