Fixed sql query statements that queried with name.