Hi Zak,

A couple ways. With your example, it's really easy to just change the
SQL statement to:

combined = db.select('mytable', where="name = $name1 or age = $age")

 However, it's probably not that simple for your case -- what you
probably want is:

return list(results1) + list(results2)

You need to cast the db.select results to a list to do list
concatenation. Database results in web.py database objects are
iterators. You can cast it to a list to use list idioms on it, but
realize that it will load the entire database result into memory. This
isn't a problem for small datasets, but for large ones the iterator
approach uses memory more efficiently.

Good luck,
Justin

On Aug 6, 9:50 am, Zak <[email protected]> wrote:
> Hey all,
> I have another newbie's question. I googled the question, but I can
> not find clues.
>
> An example code for a function, (Not real, just for showing 2
> instances of db.select):
>
> import web
> db = web.database(dbn='mysql', db='mydata', user='dbuser', pw='')
> results1 = db.select('mytable', where="name = $name1")
> results2 = db.select('mytable', where="age = $age")
> return (result1 + result2) ## wrong, return [results1, results2] is OK
>
> Can I combine the out of db.select results1 and results2 to a instance
> of db.select (Not by combining where clauses)? so the function can
> return an object.
>
> Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to