mysql 5.0基本语句_MySql 基本语句

查询a表中的所有数据

select * from a;

查询指定列的数据

select 列名1,列名2 from 表名;

||连接符,将多个列连接起来

select 列名1||列名2 from 表名;

条件查询

查询Email为空的用户信息

select * from 表名 where Email is null;

查询Email不为空的用户信息

select * from 表名 where Email is not null;

精确查找

select * from tablename where 列名='xxx';

模糊查询

select * from tablename where user_id like 'z%'; %表示0到多个字符

select * from tablename where user_id like '_m'; _表示一个字符

去重 关键字distinct

select distinct 列名1,列名2 from tablename

常用数据类型

CHAR(size)固定长度字符串类型,长度为size个字节,size最大为2000,最小值和默认值都为1

VARCHAR2(size)可变长度字符串类型,长度size个字节,size最大为4000,最小值为1,必须指定一个VARCHAR2的size

NUMBER(size)数值有效位数为size的值

NUMBER(p,s)p为总有效数据位数,取值范围38,默认38,可以用*代替。s为小数位数,取值范围-84~127,默认值取决于p,没有指定p,则s为最大范围,指定p,则s=0

date日期类型

多条件查询 or/and/in()/between...and.../not()

select * from tablename where 列名1='xxx' and 列名2='xxx';

select * from tablename where 列名1='xxx' or 列名2='xxx';

select * from tablename where name in('张三','里斯','王五');

select * from tablename where name not in('张三','里斯','王五');

左外连接    select * from [表名1] left join [表名2] where  [过滤条件]

右外连接    select * from [表名1] right join [表名2] where  [过滤条件]

全连接        select * from 表名1 a full join 表名2 b where [过滤条件]

内连接       select * from X a inner join Y  b where a.列1 = b. 列2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值