![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
SQL
我是勤奋的小菜鸟
热爱软件事业,对IT领域的软件开发和设计工作有浓厚的兴趣
展开
-
sql if判断
#判断 permission 是否等于 null ,如果是null则返回'为null'select ifnull(permission,'为null') from sys_menu#如果sex=1返回男,否则返回女select if(sex=1,'男','女') from users#判断星座select case when constellation = 1 then '处女座'when constellation = 2 then '狮子座'when constellation原创 2021-06-01 11:39:06 · 4878 阅读 · 0 评论 -
sql表基本操作
#查看表结构desc test#添加列alter table text01 add (remark varchar(40) default '无') #修改列类型和列名alter table text01 change remark remark varchar(30) default '暂无'#删除列alter table text01 drop remark #创建表create table text01( id int(22) primary key AUTO_IN原创 2021-06-01 11:37:44 · 241 阅读 · 0 评论 -
sql分页
#mysql 独有分页,起始页从0页开始select * from sys_menu limit 0,5#sqlServer独有 ,select row_number() over(order by Id) as number 返回行数,再由外层进行过滤select top 10 * from (select row_number() over(order by Id) as number,* from WosMenu) Wos where number > ((1-1)* 10);原创 2021-06-01 11:36:46 · 113 阅读 · 0 评论 -
sql多表联查
#内连接select * from user as u inner join class as c where u.uid = c.id#外连接#左外连接select * from user as u left join class as c on u.uid = c.id#右外连接:select * from user as u right join class as c on u.uid = c.id#全外连接(mysql不支持):select * fro, user as u原创 2021-06-01 11:35:52 · 127 阅读 · 0 评论 -
sql添删改查
#查询select * from sys_user;#添加insert into sys_user(username,`password`,phone,create_time) values('tom','123456','18306500667','2021-6-1')#修改update sys_user set username='admin',phone='13386459867' where user_id = 1#删除delete from sys_user where us原创 2021-06-01 11:34:29 · 188 阅读 · 0 评论 -
MySQL.zip安装
新建ini[mysql]# 设置mysql客户端默认字符集default-character-set = utf8[mysqld]#设置端口port = 3306# 设置mysql的安装目录basedir = d:\\mysql # 设置mysql数据库的数据的存放目录datadir = d:\\mysql\\data# 允许最大连接数max_connections = 200# 服务端使用的字符集默认为8比特编码的latin1字符集character-set-server =原创 2020-05-22 13:04:29 · 100 阅读 · 0 评论