On Thursday, April 11, 2019 at 6:48:14 AM UTC-7, [email protected] wrote:
>
> Hello everybody,
> Nobody can help me to solve my problem ? :(
>
>
> Le vendredi 5 avril 2019 11:42:26 UTC+2, [email protected] a écrit :
>>
>> Hello everybody. 
>>
>> I ask you because I can’t make queries in my database with the DAL as I 
>> wish.
>>
>> Here my context. I have two tables like this:
>>
>>  
>>
>> db.define_table(‘spare_parts’,
>>
>>     Field('name',…),
>>
>>     Field(‘best_price’,…)
>>
>>     Field(‘best_delay’,…)
>>
>>  
>>
>> db.define_table(‘supplier_choice’,
>>
>>     Field(‘parts’,…) #reference to spare parts id from table ‘spare_parts’
>>
>>     Field(‘supplier’,…),
>>
>>     Field(‘price’, 'decimal(10,2)' ,…),
>>
>>     Field(‘Delay’, 'integer' ,…),
>>
>>  
>>
>> In the ‘spare_parts’ table I define all my spare parts individually. 
>> There are normally no duplicates.
>>
>> In the ‘supplier_choice’ table I define a ‘supplier’, a ‘price’ and a 
>> ‘delay’ for each ‘parts’. But I can create as many lines as I want to 
>> define as many ‘suppliers’ ‘price’ or ‘delay’ for the same ‘part’.
>>
>>  
>>
>> What I want to do is a function which, for each id of the field 'parts' 
>> of 'supplier_choice', select all the lines with this id and find the 
>> ‘supplier’ with the lowest ‘price’ and the ‘supplier’ who has the shortest 
>> ‘delay’. Then, the idea is to update the 'best_price' field of the 
>> 'spare_parts' table with the name of the best price 'supplier' just find 
>> before and in the same way update the ‘best_delay’.
>>
>
That sounds to me like a join or a nested query (efficiency vs ease, as I 
understand the choice), and then sort the results or use .min() .  If you 
tried something like that, can you show us what you did and what the 
results were compared to what you expect?

 
>>
>> It's been 2 weeks since I try lots of things but all I managed to do is 
>> create bugs.
>>
>> If anyone could help me do this, it would be fantastic !!
>>
>> Thanks in advance.
>>
>>  
>>
>> Arthur
>>
>
/dps
 

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to