Fixed typo and change sql query

Fixed typo and change sql query for better search results