Fix bug in SQL request