My bad. distinct only works in select. But a grid doesn't accept a select 
only a query.

I see 3 options:
1. Don't use the grid and you can use the distinct=True in the select;
2. Use the grid and use groupby as a replacement of distinct (this is not a 
recommend use, but for some situations it works);
3. Create a view with distinct in the database (bypassing the DAL) and 
create a table for the view in web2py. Then you can use a grid.


segunda-feira, 15 de Abril de 2019 às 01:23:52 UTC+1, Jacob escreveu:
>
> Unfortunately the alternative isn't enough, I've looked into distinct = 
> True, but as I mentioned earlier I couldn't get it to work with the 
> SQLFORM.grid sorry again I'm still very new to python and web2py.
>
> My code looks like this
> controller contains:
>
> def car_records():
>
> fields =[db.car.vehicle_name, db.car.number_plate,]
>
> query = ( (db.car.id == db.number_plate.id) & (db.reg_date == 02-15-18) )
>
> grid = SQLFORM.grid(query=query, fields=fields, distinct = True) 
>
> return dict(grid=grid, fields=fields)
>
> view contains:
> {{extend 'layout.html'}}
> {{=grid}}
>
> On Sunday, April 14, 2019 at 5:17:34 PM UTC+1, Jacob wrote:
>>
>>
>> Thank you for replying couldn't get it to work with the grid but found an 
>> alternative for now.
>> On Sunday, April 14, 2019 at 9:26:18 AM UTC+1, João Matos wrote:
>>>
>>> Check distinct=True in the book.
>>>
>>> domingo, 14 de Abril de 2019 às 04:27:33 UTC+1, Jacob escreveu:
>>>>
>>>> Hello I'm new to web2py and I have a query which joins tables and 
>>>> displays the results in an SQLgrid. Within the grid of results there 
>>>> values 
>>>> which are appearing more than once due to many to many relationships is 
>>>> there a way to make it so that there are no repeating values.
>>>>
>>>

-- 
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.

Reply via email to