WHERE 常用字句

WHERE 字句
     a) Select*from bbs_user where password=123 and age=21;
     	1. 查询出年龄为21的 并且密码为123的用户 
     b) Select*from bbs_user where password=123 or age=21;
        1. 查询出年龄为21的	或者密码为123的用户 
     C) Select*from bbs_user where age!=21;
	    1. 查询出年龄不为21的 
	 d) Select*from bbs_user where age is null;
	    1. 查询出没有填写年龄字段的用户 
	 e) Select*from bbs_user where age is not null;
	    1. 查询出年龄不为空的用户 
	 f) Select*from bbs_user where age>21 and age<=30;
	    1. 查询出年龄在21到30之间的用户到30之间的用户
	 g) Select*from bbs_user where age between 21 and 30; 
	    1. 同上 
	 h) Select*from bbs_user where age not between 21 and 30;
	    1. 查询出年龄不在21岁到30岁之间的用户
	 i) Select*from bbs_user where username like "zhang%";
	    1. 查询出姓张的用户 %代表通配符 代表的意思是任意个任意字符 
		2. _代表一个任意字符
	 j) Select*from bbs_user where username not like'zhang%';
	    1. 查询出不姓张的用户 
	 K) Select*from bbs_user where id in(1,3,5) ;
	    1. 查询出id为1,3,5,7的用户 
		2. 等价于 id=1 or id=3 or id=5 or id=7
		

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值