On some orders I get the following error part way through the order when looking at a particular order in admin/customers/orders.php, after the attributes are displayed:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and pta.products_text_attributes_id = ota.products_text_attributes_id' at line 1

select ota.*, pta.products_text_attributes_name from orders_text_attributes as ota, products_text_attributes as pta where ota.orders_id = 43 and ota.products_id = and pta.products_text_attributes_id = ota.products_text_attributes_id


Since it only occurs occasionally, it doesn't seem like it is a code error, but what could cause it?

Thanks,

Dan