查看帮助文档目录列表(命令行):
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`=?
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

被折叠的 条评论
为什么被折叠?



