Fixed database query
Merge pull request #300 from Lerogero/master

Fixed database query