当前位置:Gxlcms > 数据库问题 > MySQL中一个sql语句包含in优化问题

MySQL中一个sql语句包含in优化问题

时间:2021-07-01 10:21:17 帮助过:2人阅读

module.id, module.module_name, module.module_code `module` where 92 IN (module.did_access) WHERE module.type =2 AND module.status =0 ORDER BY module.create_time ASC LIMIT 0 , 30

    这样的sql语句会有缺陷,in的用法虽然看上去没问题,但是是不对的,这样查出的数据不全,所以优化了一下:

第二版sql:

select module.id, module.module_name, module.module_code
 from `budget_project_module` as module 
where module.type=1 
and module.status=0 
and FIND_IN_SET(92, module.did_access) order by module.create_time asc

 

MySQL中一个sql语句包含in优化问题

标签:stat   bsp   mys   sele   col   sql   rom   where   sel   

人气教程排行