my sql与sql sever怎么转化
String sQuery = "select course.limited,IF(elective.course_id, count(*), 0) as amount "
+ "from course left join elective "
+ "on course.course_id = elective.course_id "
+ "where course.course_id = '" + sCourseId + "' "
+ "group by course.course_id";
什么意思,是什么语句啊,怎么用sql sever写????
------解决方案--------------------declare @sCourseId int
set @sCourseId=100 -->这是变量,外部传进来的
select course.limited, count(elective.course_id) as amount
from course
left join elective on course.course_id = elective.course_id
where course.course_id = @sCourseId
group by course.course_id
------解决方案--------------------String sQuery = "select course.limited,case when elective.course_id is null then count(*) else 0 end as amount "
+ "from course left join elective "
+ "on course.course_id = elective.course_id "
+ "where course.course_id = '" + sCourseId + "' "
+ "group by course.course_id";
你这个除了IF之外,其他都可以直接在sqlserver中使用。if等于sqlserver中的case when