On Sunday, July 22, 2018 at 7:13:13 AM UTC-4, Maurice Waka wrote:
>
> I have tried this example but I get this error below:
>
>
> db(query).delete()
>
>
Show the code for "query". Looks like it might include a Set object where a 
field or value is expected.
 

> DELETE FROM post WHERE id IN(SELECT id FROM post ORDER BY id LIMIT 50 ASC)
>
>
Does this work?

first_fifty_posts = db(db.post)._select(db.post.id, orderby=db.post.id, 
limitby=(0, 50))
db(db.post.id.belongs(first_fifty_posts)).delete()

See "nested selects" 
at 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#belongs.

Anthony

>

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