请问这个问题用if else语句怎么解决

img

请问这个问题用if else语句怎么解决?刚入门不懂,ifelse语句该怎么写

请问有没有关于if else 语句的详细用法可以参考的文件之类,学校用的教科书看不太懂

SQL语句不用if else,如涉及到是否问题,可用case when 条件为真 then 表达式1 else 表达式2 end,或者case 表达式 when 值1 then 表达式1 when 值2 then 表达式2 else 其它表达式 end。
这个题目,找找有没有可以这样:

select case when exists (select * from 选修表 where 课程='计算机基础') then '有' else '没有' end

有的话输出学生:

select 学生姓名 from 选修表 where 课程='计算机基础'