Sql Select With Substring Javascript