Browse Source

sql 优化

lihong 3 months ago
parent
commit
15d2a9a183

+ 1 - 1
src/main/java/cn/hnthyy/thmz/mapper/thmz/ClinicMapper.java

@@ -291,7 +291,7 @@ public interface ClinicMapper {
      * @param patientId
      * @return
      */
-    @Select("select dept_code from t_clinic  where patient_id = #{patientId} and doctor_code=#{doctorCode} order by op_day desc limit 1")
+    @Select("select top 1 dept_code from t_clinic  where patient_id = #{patientId} and doctor_code=#{doctorCode} order by op_day desc ")
     String selectLastByPatientIdAndDoctor(@Param("patientId") String patientId, @Param("doctorCode") String doctorCode);
 
     /**

+ 2 - 2
src/main/java/cn/hnthyy/thmz/mapper/thmz/DiscountMapper.java

@@ -228,9 +228,9 @@ public interface DiscountMapper {
             "         join t_template t2 on t1.template_id = t2.id" +
             " where t1.delete_flag = 0  and t1.discount_begin_time <=getDate() and t1.discount_end_time>=getDate()")
     List<Discount> queryTcDiscunt();
-    @Select("   select  *  from t_discount where template_id =#{templateId} limit 1")
+    @Select("   select top 1  *  from t_discount where template_id =#{templateId} ")
     Discount queryTcDiscuntByTemplateId(Long templateId);
-    @Select("   select  name from t_discount where template_id =#{templateId} limit 1 ")
+    @Select("   select top 1  name from t_discount where template_id =#{templateId}  ")
     String selectNameByTmplateId(Long templateId);
     @Select("  select  *  from t_discount where where template_id is not null")
     List<Discount> selectNotNullTemplate();