当前位置:   article > 正文

代替mysql_mysql 替代子查询

mysql 中代替子查询写法

//in子查询的写法 我自己的mysql支持 服务器不支持

(select user_no,videofile from user_info where phone in(SELECT caller from pair_info where receiver='1365555' and invite_flag=1 and read_flag=0 ) and phone not in(SELECT receiver from pair_info where caller='1365555'and receive_invite_flag=2 and createtime>=now()) and status=1 and top_flag=1 and valid_top_datetime>now() order by lastupdatetime desc) union (select user_no,videofile from user_info where phone in(SELECT caller from pair_info where receiver='1365555' and invite_flag=1 and read_flag=0 ) and phone not in(SELECT receiver from pair_info where caller='1365555' and receive_invite_flag=2 and createtime>=now()) and status=1 and top_flag=0 order by lastupdatetime desc)

//不支持in  看看 any行不,还是不行

(select user_no,videofile from user_info where phone = any (SELECT caller from pair_info where receiver='1365555' and invite_flag=1 and read_flag=0 ) and phone != any (SELECT receiver from pair_info where caller='1365555' and receive_invite_flag=2 and createtime>=now()) and status=1 and top_flag=1 and valid_top_datetime>now() order by lastupdatetime desc) union (select user_no,videofile from user_info where phone  = any(SELECT caller from pair_info where receiver='1365555' and invite_flag=1 and read_flag=0 ) and phone != any(SELECT receiver from pair_info where caller='1365555' and receive_invite_flag=2

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/在线问答5/article/detail/815681
推荐阅读
相关标签
  

闽ICP备14008679号