Home  >  Article  >  Backend Development  >  关于sql语句判断与程序判断,哪个更省时省力?解决方法

关于sql语句判断与程序判断,哪个更省时省力?解决方法

WBOY
WBOYOriginal
2016-06-13 11:51:301329browse

关于sql语句判断与程序判断,哪个更省时省力?
关于sql语句判断与程序判断,哪个更省时省力?
一,
1,select if(age>10,name,'10') as 姓名 from student;(mysql sql判断年龄大于10则查出姓名)
2,循环展示在前台
二,
1,select name from student;
2,程序判断年龄大于10并循环显示在前台
问:
关于第一和第二两种方法,哪个更省时省力?(可以不局限于上面的例子)
------解决方案--------------------
自己测试下看下两个方法的执行时间不久不知道了吗
------解决方案--------------------
sql快,前提是age字段做索引。
你想,要是你有一百万条记录,也读到数组里然后遍历么?
------解决方案--------------------
sql比程序快。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn