Fixed db query
Merge pull request #274 from Lerogero/master

Fixed db query