2010-09-04 23 views
0

我的下列sql查詢給了我下面的錯誤,這是什麼意思。我是否正在用扭曲的方式定義別名fir列。這個你能幫我嗎。 我的錯誤是這個,我正在查詢下面的錯誤。SQL查詢定義列別名的錯誤

Error in SELECT clause: expression near 'Year'. 
Missing FROM clause. 
Unable to parse query text. 



SELECT [tbl_students].passing_year as Passing Year,[tbl_branch].branch_name as Branch_Name FROM [tbl_students], [tbl_course], [tbl_branch] WHERE [tbl_students][email protected] 
         AND [tbl_students].branch_id IN(64) 
         AND [tbl_students].course_id=[tbl_course].course_id AND [tbl_students].branch_id=[tbl_branch].branch_id       
         AND (@firstYrPercent is null OR [tbl_students].first_year_percent>[email protected]) 
         AND (@secondYrpercent is null OR [tbl_students].second_year_percent>[email protected]) 
         AND (@thirdYrPercent is null OR[tbl_students].third_year_percent>[email protected]) 
         AND (@finalYearpercent is null OR [tbl_students].final_year_percent>[email protected]) 
         AND (@currentDegeePercentage is null OR [tbl_students].current_degree_percent>[email protected]) 
         AND (@passoutYear is null OR [tbl_students].passing_year>[email protected]) 
         AND (@currentBacklog is null OR [tbl_students][email protected]) 
         AND (@sex is null OR [tbl_students][email protected]) 
         AND (@eGap is null OR [tbl_students].gapin_education<[email protected]) 
         AND (@highSchoolPercentge is null OR [tbl_students].highschool_percentage>[email protected]) 
         AND (@higherSchoolPercentage is null OR [tbl_students].ssc_percentage>[email protected]) 
         AND (@grauationPercentage is null OR [tbl_students].graduation_percentage>[email protected]) 
         AND (@diplomaPercentage is null OR [tbl_students].diploma_percentage>[email protected]) 
         AND (@noOfAtkt is null OR [tbl_students].number_of_ATKT<[email protected]) 
         AND (@validDate is null OR [tbl_students].DOB>[email protected]) 
+0

我不能給差距在ASP中SQL查詢的列alises的名稱。淨 – NoviceToDotNet 2010-09-04 13:04:41

回答

2

你需要逃避你傳遞新年用方括號列(見第一行):

SELECT [tbl_students].passing_year as [Passing Year], 
     [tbl_branch].branch_name as Branch_Name 
FROM [tbl_students], [tbl_course], [tbl_branch] 
WHERE [tbl_students][email protected] 
AND [tbl_students].branch_id IN(64) 
AND [tbl_students].course_id=[tbl_course].course_id AND [tbl_students].branch_id=[tbl_branch].branch_id       
AND (@firstYrPercent is null OR [tbl_students].first_year_percent>[email protected]) 
AND (@secondYrpercent is null OR [tbl_students].second_year_percent>[email protected]) 
AND (@thirdYrPercent is null OR[tbl_students].third_year_percent>[email protected]) 
AND (@finalYearpercent is null OR [tbl_students].final_year_percent>[email protected]) 
AND (@currentDegeePercentage is null OR [tbl_students].current_degree_percent>[email protected]) 
AND (@passoutYear is null OR [tbl_students].passing_year>[email protected]) 
AND (@currentBacklog is null OR [tbl_students][email protected]) 
AND (@sex is null OR [tbl_students][email protected]) 
AND (@eGap is null OR [tbl_students].gapin_education<[email protected]) 
AND (@highSchoolPercentge is null OR [tbl_students].highschool_percentage>[email protected]) 
AND (@higherSchoolPercentage is null OR [tbl_students].ssc_percentage>[email protected]) 
AND (@grauationPercentage is null OR [tbl_students].graduation_percentage>[email protected]) 
AND (@diplomaPercentage is null OR [tbl_students].diploma_percentage>[email protected]) 
AND (@noOfAtkt is null OR [tbl_students].number_of_ATKT<[email protected]) 
AND (@validDate is null OR [tbl_students].DOB>[email protected])