mysql谓词连接是啥_MYSQL谓词的使用和表达式

in//使用IN谓词将一个值与其他几个值进行比较

select * from users where id in(1,2,5);相当于select * from users where id=1 or id=2 or id=5;

6a4acc32594a1fbd8c756b412a0d4669.png

between//将单一值与一个范围内的值比较

select * from users where id between 2 and 4;相当于select * from users where id>=2 and id<=4;

fe3079c2bee8e29a4b4abc57640c2907.png

like//搜索具有某些模式的字符串。通过百分号和下划线指定模式。

76fd39bb073f33014c67dce9fe2633f8.png

exists//测试某个条件的行的存在性

表达式>ALL//表达式大于由全查询返回的每个单值

表达式>ANY//表达式至少大于由全查询返回的值之一

条件表达式:

select id,case name

when '高某' then 'gp'

when '曹某' then 'cw'

when '唐某' then 'tg'

else 'wz'

end as nname

from users;

嵌套表表达式:

select id,name,gender,birthday,address

from(

select id,name,gender,birthday,address from users where address='北京'

)as newusers

where id<3;

c99e97cb22a557df61c40d1dcbc3321e.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值