sql异常(''附近的语法不正确'。)

时间:2010-08-17 06:52:51

标签: sql

上述错误是什么,请更正

string cmd = @"SELECT * FROM [tbl_students] WHERE course_id=@courseId 
               AND   branch_id IN(" + branchId + @") 
               AND  (@firstYrPercent is null OR first_year_percent>=@firstYrPercent
               AND  (@secondYrpercent is null OR second_year_percent>=@secondYrPercent)
               AND  (@thirdYrPercent is null OR third_year_percent>=@thirdYrPercent)
               AND  (@finalYearpercent is null OR final_year_percent>=@finalYearpercent)
               AND  (@currentDegeePercentage is null OR current_degree_percent>=@currentDegeePercentage)
               AND  (@passoutYear is null OR passing_year>=@passoutYear) 
               AND  (@currentBacklog is null OR current_backlog<=@currentBacklog)
               AND   gender=@sex 
               AND  (@eGap is null OR gapin_education<=@eGap)
               AND  (@highSchoolPercentge is null OR highschool_percentage>=@highSchoolPercentge)
               AND  (@higherSchoolPercentage is null OR ssc_percentage>=@higherSchoolPercentage)
               AND  (@grauationPercentage is null OR graduation_percentage>=@grauationPercentage)
               AND  (@diplomaPercentage is null OR diploma_percentage>=@diplomaPercentage)
               AND  (@noOfAtkt is null OR number_of_ATKT<=@noOfAtkt)
               AND  (@date is null OR DOB>=@date)";

2 个答案:

答案 0 :(得分:3)

第3行末尾缺少右括号:

AND  (@firstYrPercent is null OR first_year_percent>=@firstYrPercent

答案 1 :(得分:1)

以下行没有右括号

   AND  (@firstYrPercent is null OR first_year_percent>=@firstYrPercent