And it's better not to hardcode the notes table name.

I would try a query like this:
Code:
$notes_active_query = ("SELECT * FROM " . TABLE_NOTES . " WHERE customers_id='" . $orders->fields['customers_id']  . "'");
And if you only need the notes_id anyway you can also use:
Code:
$notes_active_query = ("SELECT notes_id FROM " . TABLE_NOTES . " WHERE customers_id='" . $orders->fields['customers_id']  . "'");
to save some more resources