thinkphp5.1使用sql,Between语句

$select = Db::name(‘table’)->whereBetween( “time” , s t a r t " , " . start",". end )->select();
当然使用前要记得引入Db类哦。
s t a r t start是区间值的开始, end是区间值的结尾。
time指的是表table的字段。
意思就是查询time这个字段区间值是 s t a r t start到 end的数据。
举个栗子。

这是新建的一个ceshi表,接下来我们要查询cs字段中区间值是1到35之间。
在这里插入图片描述
这里是代码,可以看到我查询表ceshi的字段cs区间值在1到35之间,然后打印。
在这里插入图片描述
大功告成,接下来上代码!!!
public function cs()
{
d a t a = D b : : n a m e ( c e s h i ) > w h e r e B e t w e e n ( c s , 1 . , . 3 5 ) > s e l e c t ( ) ; d u m p ( data = Db::name('ceshi')->whereBetween('cs','1'.','.'35')->select(); dump( data);
}

希望大家可以点个赞哦 !

发布了4 篇原创文章 · 获赞 10 · 访问量 181

猜你喜欢

转载自blog.csdn.net/DarKer_LB/article/details/103143530