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

WBOY
Release: 2016-06-23 14:00:39
Original
853 people have browsed it

关于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比程序快。

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template