SQL语句这样的写法是否存在问题
select * from (select * from xf_art where flag=3 order by add_time desc) a,(select id userid,username from xf_usr where flag!=9 ) u where a.xfuid=u.userid order by a.add_time desc
以上的sql语句是我一个已离职的同事写,运行正常,但是怎么看都觉得有点别扭,SQL语句这样的写法是否存在问题呢?问题再在哪里(我现在也说不出来,所以请教各位了)
------解决方案--------------------
语句没问题,效率可能有些问题,用explain查一下。
explain select * from (select * from xf_art where flag=3 order by add_time desc) a,(select id userid,username from xf_usr where flag!=9 ) u where a.xfuid=u.userid order by a.add_time desc <br><font color="#e78608">------解决方案--------------------</font><br>没有问题,从性能来看,第一个order by add_time desc可以不需要。 <br><font color="#e78608">------解决方案--------------------</font><br>这样的sql语句没问题 是可以运行的 但是执行的效率还要进一步的修改了。<br><br>他就是 select * from 表a , 表u where a.xfuid=u.userid;<br>a 是个表 这个表不是数据库现有的 而是通过某种条件查询出的表。 <div class="clear"></div>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号