Fix SQL error for missing AND operator

AND operator was missing from WHERE clause
Merge pull request #641 from oohlaf/master

Fix SQL error