03表查询

#CREATE database lianxi;    #创建数据库

use lianxi;  

CREATE table customer(id VARCHAR(30),age int,name VARCHAR(30),birthday date);  #创建表

show tables;

insert into customer(id ,age,name,birthday) values('01','18','小马','98-08-28');

insert into customer(id ,age,name,birthday) values('02','18','小雄','98-10-09');


insert into customer(id ,age,name,birthday) values('03','18','小李','98-01-01');

select * from customer;  #  表中的所有记录

update customer set age = '19', name = '小李'  where id='03' #修改记录

select * from customer;  #  表中的所有记录


#删除记录: delete from 表名 where ….



SELECT id,name from customer ;#查询特定的列


SELECT id,name from customer where id>1; #对查询的数据进行过滤
SELECT id,name from customer where id>1 and id<3;
SELECT id,name from customer where id in (2,3);
SELECT id,name from customer where id between 2 and 3;
SELECT id,name from customer where like '_%';

SELECT id,name from customer where age is null;
#查询 age 为 空 的所有人的信息

SELECT * from customer order by age;#排序


select * from customer;


SELECT * from customer order by age desc  #降序排序


SELECT id AS xuhao, age nianling FROM customer;  #列的别名, 
#可以在列名和别名之间加入关键字‘AS’,或者不需要加

describe customer; #显示表结构
desc customer; #查看表结构
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值