Fixed sql query issue
Merge pull request #429 from sheebans/master

Fixed sql query issue