CRAFTERCMS-879

Fixed SQL query causing issue.