thinkphp where条件语句整理
| TP运算符 | SQL运算符 | 例子 | 实际查询条件 |
|---|---|---|---|
| eq | = | $map['id'] = array('eq',100); | 等效于:$map['id'] = 100; |
| neq | != | $map['id'] = array('neq',100); | id != 100 |
| gt | > | $map['id'] = array('gt',100); | id > 100 |
| egt | >= | $map['id'] = array('egt',100); | id >= 100 |
| lt | < | $map['id'] = array('lt',100); | id < 100 |
| elt | <= | $map['id'] = array('elt',100); | id <= 100 |
| like | like | $map<'username'> = array('like','Admin%'); | username like 'Admin%' |
| between | between and | $map['id'] = array('between','1,8'); | id BETWEEN 1 AND 8 |
| not between | not between and | $map['id'] = array('not between','1,8'); | id NOT BETWEEN 1 AND 8 |
| in | in | $map['id'] = array('in','1,5,8'); | id in(1,5,8) |
| not in | not in | $map['id'] = array('not in','1,5,8'); | id not in(1,5,8) |
| and(默认) | and | $map['id'] = array(array('gt',1),array('lt',10)); | (id > 1) AND (id < 10) |
| or | or | $map['id'] = array(array('gt',3),array('lt',10), 'or'); | (id > 3) OR (id < 10) |
| xor(异或) | xor | 两个输入中只有一个是true时,结果为true,否则为false,例子略。 | 1 xor 1 = 0 |
| exp | 综合表达式 | $map['id'] = array('exp','in(1,3,8)'); | $map['id'] = array('in','1,3,8'); |
补充说明
- 同 SQL 一样,ThinkPHP运算符不区分大小写,eq 与 EQ 一样。
- between、 in 条件支持字符串或者数组,即下面两种写法是等效的:
$map['id'] = array('not in','1,5,8');
$map['id'] = array('not in',array('1','5','8'));
thinkphp where条件语句整理的更多相关文章
- C#整理 条件语句
条件语句主要分为if else语句和switch case语句. if else语句主要分为四种格式: 1. if(表达式) {} 2.二选一 if(表达式) {} else {} 3.多选一 if( ...
- mysql copy表或表数据常用的语句整理汇总
mysql copy表或表数据常用的语句整理汇总. 假如我们有以下这样一个表: id username password ----------------------------------- 1 a ...
- shell脚本进阶之条件测试与条件语句
接着上篇博客,今天整理一下关于条件测试和条件语句方面的知识. shell脚本进阶之条件测试 在编写shell脚本时,经常需要对一些条件进行判断,可以使用测试命令test辅助完成测试过程.t ...
- 常用sql语句整理:mysql
## 常用sql语句整理:mysql1. 增- 增加一张表```CREATE TABLE `table_name`( ... )ENGINE=InnoDB DEFAULT CHARSET=utf8 ...
- JS 优化条件语句的5个技巧
前言 在使用 JavaScript 的时候,有时我们会处理大量条件语句,这里有5个技巧帮助我们编写更简洁的条件语句. 一.对多个条件使用 Array.includes 例子: function con ...
- 孤荷凌寒自学python第十四天python代码的书写规范与条件语句及判断条件式
孤荷凌寒自学python第十四天python代码的书写规范与条件语句及判断条件式 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 在我学习过的所有语言中,对VB系的语言比较喜欢,而对C系和J系 ...
- Oracle数据库常用的Sql语句整理
Oracle数据库常用的Sql语句整理 查看当前用户的缺省表空间 : select username,default_tablespace from user_users; 2.查看用户下所有的表 : ...
- if-else 条件语句
1. 条件语句模型 Go里的流程控制方法还是挺丰富,整理了下有如下这么多种: if - else 条件语句 switch - case 选择语句 for - range 循环语句 goto 无条件跳 ...
- Python——条件语句及其循环
条件语句及其循环 一. 条件语句 在条件语句中可以使用以下所有的运算符: 算术运算符:+.-.*././/.%.** 关系运算符:>.<.==.<=.>=.!= 测试运算符:i ...
随机推荐
- jquery实现表格的搜索功能
版权声明:作者原创,转载请注明出处! HTML代码如下: <input type="text" id="txt" value="" / ...
- 把Sharepoint Desinger 工作流部署到生产环境
下面是比较简单的方法,把Designer工作流从开发环境部署到生产环境. 在Sharepoint Desinger 2013 中点击需要部署的工作流. 点击保存,发布. 点Export to Visi ...
- iOS之常用宏定义
下面我为大家提供一些常用的宏定义! 将这些宏定义 加入到.pch使用 再也不用 用一次写一次这么长的程序了 //-------------------获取设备大小------------------- ...
- [Animatable Properties](https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CoreAnimation_guide/AnimatableProperties/AnimatableProperties.html)
 
- DropDownList默认选中
一.DropDownList默认选中 开始的笨方法: foreach (ListItem item in DropDownList1.Items) { ...
- iOS--UILable自适应大小
#import "ViewController.h" @interface ViewController () @property(strong,nonatomic) UILabe ...
- 移动端rem布局实践
一.rem 适配基本概念: 对于移动端的开发,rem 适配必不可少,我们可以用多种方式实现, 根据 html 的 fontSize 属性值为基准,其它所有的 rem 值,根据这个基准计算.我们根据 ...
- Play Framework 完整实现一个APP(十)
1.定制Comment列表 新增加Comment list页面,执行命令行 > play crud:ov --template Comments/list 会生成/app/views/Comme ...
- RMAN异机还原遭遇ORA-19698错误案例
实验环境: 操作系统 :Oracle Linux Server release 5.7 64 bit 数据库版本:Oracle Datab ...
- 【转】hive导入数据出现NULL
在把hdfs上数据迁移到hive中的表时,若出现数据位NULL,是因为没有指定列分隔符. 由于hive默认的分隔符是/u0001(Ctrl+A),为了平滑迁移,需要在创建表格时指定数据的分割符号,语法 ...