select id, name, category_id, status, del_flag,company_id,privatize,version, create_by, create_time, update_by, update_time, remark,
(select count(1) from ex_question where bank_id=a.id) as total_count
from ex_question_bank
update ex_question_bank set del_flag=1 where id=#{bankId}
select id,name from ex_question_bank where name=#{name} and privatize=1 and del_flag=0 limit 1
select id,name from ex_question_bank where name=#{name} and company_id=#{companyId} and del_flag=0 limit 1
and del_flag=0
AND name like concat('%', #{name}, '%')
AND categoryId =#{categoryId}
AND status =#{status}
AND (company_id =#{companyId} or privatize=1)
order by id desc
select a.*,
(select count(1) from ex_question where bank_id=a.id) as total_count,
b.exe_count as exercise_count
from ex_question_bank a
left join (select bank_id,count(*) as exe_count from ex_exercise_answer where student_id=#{studentId} group by bank_id) b on b.bank_id=a.id
and (a.company_id=#{companyId} or a.privatize=1) and a.del_flag=0
a.name like concat('%',#{name},'%')
order by a.id desc
select a.*,
(select count(1) from ex_question where bank_id=a.id) as total_count,
(select count(1) from ex_exercise_answer where bank_id=#{bankId} and student_id=#{studentId}) as exercise_count
from ex_question_bank a
where a.bank_id=#{bankId}