That's what I was thinking. list: type fields are good if you just need to store a list of things associated with a given record and retrieve the list when the record is retrieved, but they aren't necessarily easy or efficient for querying the data (depending on the application). If you really want to stick with the list: fields, I suppose you could do a select to get the Julia records, and then use some Python code to further filter the records based on status. You might also be able to create either a computed or virtual field that concatenates name and status into a new list, and query that. Depending on how many records you're dealing with, though, it might be more efficient to go with a more normalized data structure.
Anthony On Wednesday, October 26, 2011 5:38:41 PM UTC-4, Archibald Linx wrote: > > Dear Anthony, > > I have asked the question on Stackoverflow and it seems it is a bad > database structure ;) Sorry. > > See : http://stackoverflow.com/questions/7908024/sql-query-list-fields > > I will put the status information somewhere else. Maybe in a separate > database. I don't know yet. > > Thanks for the help you gave me, > Archibald > > > On 26 oct, 20:35, Archibald Linx <archib...@gmail.com> wrote: > > Thank you Anthony. > > > > I don't know about the raw SQL query. I will ask on Stackoverflow and > > post the link here. > > > > Best, > > Archibald > > > > On 26 oct, 19:07, Anthony <abas...@gmail.com> wrote: > > > > > > > > > > > > > > > > > On Wednesday, October 26, 2011 12:21:33 PM UTC-4, Archibald Linx > wrote: > > > > > > Thank you Anthony ! > > > > > > Is the length "len" always defined in Python ? > > > > > No, I think the len() function will fail if you pass None to it, so if > you > > > were using request.vars, you'd want something like: > > > > > default=len(request.vars.to) if request.vars.to is not None else > [whatever > > > you want the default to be otherwise] > > > > > > I couldn't find much tools in the documentation to query lists of > > > > references apart from the "contains" operator. > > > > > > For example, let's have the following "message" table : > > > > id / to / status > > > > 1 / steve,jimmy / 0,2 > > > > 2 / john,julia / 1,2 > > > > 3 / julia,peggy / 0,1 > > > > > > I want to get the rows where "Julia" is in "to" and where her status > > > > is "0" (in this particular case, that is row n°3). > > > > With the "contains" operator I only know how to get the rows where > > > > "Julia" is in "to" (that is row n°2 and n°3). > > > > > > Should I write raw SQL ? > > > > > How would you write it in raw SQL?