mysql条件查询语句

2023年 2月 17日 49.6k 0

mysql条件查询语句

mysql查询语句条件语句中能用函数吗

可以使用的,比如
select * from user where birt村质湖顶架买hdate=rtrim(来自#{birthdata})


mysql动态多条件查询语句!!!!

select * from table where (name1 like '%key1%' or name2 like '%key2%' or name3 like '%key3%')

同理,你还可以任意再次组合,用or连接就行

如再上 name1 like key1 or name1 like key2 or name1 like key3

name2 like key1 or name2 like key2 or name2 like key3

等等


mysql数据库sql查询语句:多条件判断

1、创建测试表,

create table test_person(id int, RMB int);

2、插入测试数据

insert into test_person values(1,180);

insert into test_person values(2,170);

insert into test_person values(3,290);

insert into test_person values(4,160);

insert into test_person values(5,299);

insert into test_person values(6,266);

insert into test_person values(7,155);

3、查询表中所有记录,select t.* from test_person t,

4、编写sql,汇总每个vip类型的用户数,

select vip_type, count(distinct id)

from (select case when RMB>100 and RMB<200 then 'VIP1' when RMB>200 then 'VIP2' end as vip_type, id

from test_person) t

group by vip_type


相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论