Fix bug - refs BT#8525

I am not sure about this change of query and the impact it might have. Please review and/or explain how the change does *not* impact the data.