Hello,
I'm sorry if I did not post my tests but I’m really beginner with web2py, python... and I was a little afraid to look ridiculous.. (Sorry again but my English is ridiculous too !!). First I tried with Mysql trough MysqlWorkbench and I quickly success to get the minimum but only for a specific id with a simple SELECT and MIN(price). When I tried to do the same thing for all existing spare parts, I stopped with that because I blocked and got nothing good. DROP PROCEDURE IF EXISTS test; DELIMITER | CREATE PROCEDURE test() BEGIN DECLARE c_id INT(11); DECLARE cursor_id CURSOR FOR SELECT id FROM parts ORDER BY id; OPEN cursor_id; id_loop: LOOP FETCH cursor_id INTO c_id; IF c_id = 3 THEN LEAVE id_loop; END IF; SELECT parts, supplier, price FROM supplierchoice ORDER BY parts; INSERT INTO V_select_supchoice (parts, supplier, price) SELECT (parts, supplier, MIN(price)) WHERE parts = c_id; END LOOP; CLOSE cursor_id; END | DELIMITER ; Then I tried to do it by referring to what I found in the web2py manual. That’s where I am now. This is only for the price but it’s the same for the delay. partid = db().select(db.parts.id) for i in partid: query = db.supplierchoice.parts == i rows = db(query).select(db.supplierchoice.parts, db.supplierchoice.supplier, db.supplierchoice.price.min()) response.flash = rows I tried to show the result in a response.flash message before performing an update of the fields best_price and best_delay of the table spare_parts to avoid breaking everything but it shows me something that looks nothing good. Depending on the tests, I get two different results: either web2py is KO or my response.flash is very strange. Thank you both for taking the time to answer me even though I did not have much detail. Arthur -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.