查看帮助文档目录列表(命令行):

help contents;

查看帮助文档具体内容:

help 目录内容;

查看数据库:

show databases

查看数据库中包含的所有表:

show tables

查看指定表结构:

describe bill
desc bill

查看默认存储引擎:

show variables like `storage_engine%`;

查询表数据:

select 字段名|表达式|函数|常量 from `表名` where ..... order by .... group by ..... limit ...

常量列:

select `studentNo` as '学号','常量列数据' as '别名' from .....

子查询:

SELECT * FROM `student` WHERE 字段 比较运算符(子查询语句)
SELECT * FROM `student` WHERE 字段 INT(子查询语句)
SELECT * FROM `student` WHERE 字段 NOT IN(子查询语句)
SELECT * FROM `student` WHERE EXISTS(子查询语句)
SELECT * FROM `student` WHERE NOT EXISTS(子查询语句)




分组查询:

select * from `student` group by `字段1`,`字段2`.......


分组筛选查询:

SELECT * FROM `student` GROUP BY `字段1`,`字段2`....... HAVING 限制条件如:studentNo>2

内连接查询:

select cus.`cusName`,cus.`cusSex`,cus.cusIdNo,cus.`cusPhone`,
chec.`roomId`,chec.`checkInDate`,chec.`checkOutDate`,roomt.`price`,
chec.`deposit`,chec.`checkInId` from `checkIn` chec 
join `room` r on r.`roomId`=chec.`roomId` 
join `roomType` roomt on r.`typeId`=roomt.`typeId` 
join `customer` cus on cus.`cusId`=chec.`cusId` 
where r.`roomId`=? and r.`status`=? and chec.`billstate`=?


左外连接查询(结果包含左表所有行,若右表没有匹配则填上NULL):

select cus.`cusName`,cus.`cusSex`,cus.cusIdNo,cus.`cusPhone`,
chec.`roomId`,chec.`checkInDate`,chec.`checkOutDate`,roomt.`price`,
chec.`deposit`,chec.`checkInId` from `checkIn` chec 
left join `room` r on r.`roomId`=chec.`roomId` 
left join `roomType` roomt on r.`typeId`=roomt.`typeId` 
left join `customer` cus on cus.`cusId`=chec.`cusId` 
where r.`roomId`=? and r.`status`=? and chec.`billstate`=?

右外连接查询(结果包含右表所有行,若左表没有匹配则填上NULL):
select cus.`cusName`,cus.`cusSex`,cus.cusIdNo,cus.`cusPhone`,
chec.`roomId`,chec.`checkInDate`,chec.`checkOutDate`,roomt.`price`,
chec.`deposit`,chec.`checkInId` from `checkIn` chec 
right join `room` r on r.`roomId`=chec.`roomId` 
right join `roomType` roomt on r.`typeId`=roomt.`typeId` 
right join `customer` cus on cus.`cusId`=chec.`cusId` 
where r.`roomId`=? and r.`status`=? and chec.`billstate`=?

查看索引:

SHOW INDEX 索引名 FROM 表名  列较多的情况后面加\G 









评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值