list:string field values are stored as simple strings with the items 
delimited by "|" characters (the values are converted to/from lists during 
the select/insert process on the web2py side). So, a value with one tag 
would like like "|tag|", and a value with more than one tag would therefore 
have at least one additional "|" character in between the opening and 
closing "|", which leads to the following query:

db(db.sample_table.tags.like('|%|%|')).select()

Note, that will also include records with a single tag if that single tag 
happens to include a "|" character within it (which presumably would be 
quite rare, if not prohibited).

Anthony

On Monday, February 24, 2014 1:44:39 PM UTC-5, Kök Eksi Bir wrote:
>
> How do I write a query that selects rows having more than one item in 
> list:string field?
> Assume I have a table definition
>
> db.define_table('sample_table',
>     ....
>     Field('tags', 'list:string'),
> )
>
> How can I select rows that have more than one tag?
>
> Regards,
>

-- 
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/groups/opt_out.

Reply via email to