I am trying to export all rows from two tables, (e.g. purchase orders, and 
items) into a csv file, but if possible would like to export a single row 
per each purchase order (with belonging items divided into separate columns 
of the same row). I'm using MySQL, if it makes the difference.

I read some comments about using the Expression or a function (from 
gluon.sql import Expression), but don't know how to go about it. Any advise?

Thanks,
Adnan

>>> rows = db(db.purchase_order.id>0).select(db.purchase_order.po_number, 
db.item.id, left=db.item.on(db.purchase_order.id==db.item.po_id))
>>> print rows

results:
purchase_order.po_number,item.id
201201120001,31
201201120001,41
201201120001,51
201201120001,61
201201160004,111
201201170005,151
201201006,161

would prefer to have it like this: 
201201120001,31,41,51,61
201201160004,111
201201170005,151
201201006,161

Reply via email to