字段去重查询

select distinct style from music

批量修改某字段

update music set style = "ost"  where style like "%影视剧%"

先查询,再添加或修改数据字段

select * from music where language  is null

update music set language = "外国" where language is null

mysql的sql实现

mysql> alter table 国产 rename to guochan;
习惯上函数用大写,但小写也可以
mysql> select now();
select ascii('f');
返回字符串str的第一个字符的ASCII值(str是空串时返回0),总是加单引号。
select CHAR(77,121,83,86,77);
增删改查语句

MariaDB [EMP]> insert into Employees values (100,18,'aa','bb');
Query OK, 1 row affected (0.02 sec) MariaDB [EMP]> insert into Employees values (101,19,'a2','b2');
Query OK, 1 row affected (0.02 sec) MariaDB [EMP]> insert into Employees values (101,19,'zara','b3');
Query OK, 1 row affected (0.01 sec) MariaDB [EMP]> insert into Employees values (105,30,'a4','b4');
Query OK, 1 row affected (0.01 sec) MariaDB [EMP]> select * from Employees;
+-----+-----+-------+------+
| id | age | first | last |
+-----+-----+-------+------+
| 100 | 18 | aa | bb |
| 101 | 19 | a2 | b2 |
| 101 | 19 | zara | b3 |
| 105 | 30 | a4 | b4 |
+-----+-----+-------+------+
4 rows in set (0.00 sec) MariaDB [EMP]> UPDATE Employees SET id=102 WHERE first='zara';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [EMP]> select * from Employees;
+-----+-----+-------+------+
| id | age | first | last |
+-----+-----+-------+------+
| 100 | 18 | aa | bb |
| 101 | 19 | a2 | b2 |
| 102 | 19 | zara | b3 |
| 105 | 30 | a4 | b4 |
+-----+-----+-------+------+
4 rows in set (0.00 sec) MariaDB [EMP]> delete from Employees where id=105;
MariaDB [EMP]> select * from Employees;
+-----+-----+-------+------+
| id | age | first | last |
+-----+-----+-------+------+
| 100 | 18 | aa | bb |
| 101 | 19 | a2 | b2 |
| 102 | 19 | zara | b3 |
+-----+-----+-------+------+
3 rows in set (0.00 sec) MariaDB [EMP]> insert into Employees values(108,29,'wu','ma');
Query OK, 1 row affected (0.03 sec) MariaDB [EMP]> insert into Employees values(109,26,'wang','wei');
Query OK, 1 row affected (0.02 sec) MariaDB [EMP]> select * from Employees;
+-----+-----+-------+------+
| id | age | first | last |
+-----+-----+-------+------+
| 100 | 18 | aa | bb |
| 101 | 19 | a2 | b2 |
| 102 | 19 | zara | b3 |
| 108 | 29 | wu | ma |
| 109 | 26 | wang | wei |
+-----+-----+-------+------+
5 rows in set (0.00 sec) show variables like '%FOREIGN%';
SET FOREIGN_KEY_CHECKS=0; delete from geographical_position where type = 1
select distinct type from geographical_position mysql> create user 'ab'@'localhost' identified by 'weeee';
mysql> select user,host,password from mysql.user; INSERT(str,pos,len,newstr)
instr mysql> select instr('contents','t');
+-----------------------+
| instr('contents','t') |
+-----------------------+
|                     4 |
+-----------------------+
1 row in set (0.00 sec) mysqldump -u root -d -R --add-drop-table spa >spa.sql
sed -i '1i\use spa;' spa.sql
sed -i '1i\create database spa;' spa.sql
sed -i '1i\drop database if exists spa;' spa.sql
mysqldump -u root   --add-drop-table spa action_buttons>>spa.sql
mysqldump -u root   --add-drop-table spa menu>>spa.sql
mysqldump -u root   --add-drop-table --extended-insert=false spa tb_sequence>>spa.sql
mysqldump -u root   --add-drop-table spa role --where="id=20" >>spa.sql
mysqldump -u root   --add-drop-table spa role_button_relation --where="role_id=20" >>spa.sql
mysqldump -u root   --add-drop-table spa user_role_relation --where="role_id=20" >>spa.sql
mysqldump -u root   --add-drop-table spa system_user --where="username='admin'" >>spa.sql -d, --no-data       No row information.
-R, --routines      Dump stored routines (functions and procedures). select * from tb_sequence limit 0,1
limit是mysql的语法
select * from table limit m,n
其中m是指记录开始的index,从0开始,表示第一条记录
n是指从第m+1条开始,取n条。
select * from tablename limit 2,4
即取出第3条至第6条,4条记录 [root@db mysql]# mysqlshow
[root@db mysql]# mysql -e 'select user,password,host from mysql.user'
mysql> delete from user where user = '';    删除匿名用户
mysql> drop user ''@localhost ;

最新文章

  1. activity 所需jiar包
  2. git基本技巧及进阶
  3. Docker Machine v1.11.2安装与使用
  4. android 去掉标题
  5. Untiy3D - 窗口界面2
  6. php有效的过滤html标签,js代码,css样式标签
  7. ASCII编码表
  8. hive 中 union all
  9. [Java] 实现一个基于命令行的用户管理
  10. C#实现大数字的运算
  11. ARM系列产品
  12. html 学习笔记--基础篇
  13. Swing布局管理器
  14. LOVEU
  15. Android+NDK+OpenGLES开发环境配置
  16. 消息同步调用-- ESFramework 4.0 进阶(07)
  17. 开发环境---->服务器(数据库迁移Migration)
  18. thinkphp 5.6以上版本出现No input file specified解决办法
  19. ACM10.14题解
  20. 廖雪峰Java2面向对象编程-4抽象类和接口-2接口

热门文章

  1. UIkit框架之UItableview
  2. 如何将内存图像数据封装成QImage
  3. 【LeetCode OJ】Populating Next Right Pointers in Each Node II
  4. JQuery源码分析(四)
  5. HDU 4971 (最小割)
  6. 第二个Sprint冲刺第四天
  7. uninstall gitlab
  8. Codis 集群搭建
  9. 使用批处理文件,自动设置计算机IP地址
  10. 转载:LBP代码详细注释