mysql子查询中的陷阱

来源:互联网 发布:java 双亲委派 编辑:程序博客网 时间:2024/04/30 13:24

今天和同事解决生产环境的问题时,发现mysql中子查询的一个bug, 之前做开发都没发现,尴尬ing!

子查询语句如下:

       

delete FROM `o2o_mh_shop_schedule_res` where shop_code = 'G05100104' and  batch_code = 'G05100104-510-1234567-10002230'and resource_id in (select id from o2o_user where resource_code in ( '11441','11444','11445'))
查询结果,截图如下

    而实际上呢,上面的子查询

<span style="white-space:pre"></span>select id from o2o_user where resource_code in ( '11441','11444','11445')
    查询结果如下:

   

看出问题了吧,这个陷阱确实有点坑啦,今天发现了,分享给友们!

0 0