找到 4379 篇文章 关于 MySQL
2K+ 次浏览
要在 group_concat() 函数中使用换行符,请遵循以下语法:select group_concat(concat_ws(' ', yourColumnName1, yourColumnName2) SEPARATOR "\r") from yourTableName; 让我们先创建一个表:mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(20), LastName varchar(20) ); 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable(FirstName, LastName) values('John', 'Smith'); mysql> insert into DemoTable(FirstName, LastName) values('David', 'Miller'); mysql> insert into DemoTable(FirstName, LastName) values('John', 'Doe'); ... 阅读更多
121 次浏览
您可以为此使用 MySQL 的 CONCAT() 函数。让我们先创建一个表:mysql> create table DemoTable ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientFirstName varchar(20), ClientLastName varchar(20) ); 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable(ClientFirstName, ClientLastName) values('John', 'Smith'); mysql> insert into DemoTable(ClientFirstName, ClientLastName) values('John', 'Miller'); mysql> insert into DemoTable(ClientFirstName, ClientLastName) values('Carol', 'Taylor'); mysql> insert into ... 阅读更多
4K+ 次浏览
首先,您需要启用 innodb_print_all_deadlocks。以下是语法:set global innodb_print_all_deadlocks=1; 执行上述语句后,让我们执行以下语法以显示所有死锁日志:show engine innodb status; 让我们实现上述语法:mysql> set global innodb_print_all_deadlocks=1; mysql> show engine innodb status; 这将产生以下输出:+--------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Type | Name | Status ... 阅读更多
272 次浏览
让我们先创建一个表:mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value char(1) ); 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable(Value) values('X'); mysql> insert into DemoTable(Value) values('Y'); mysql> insert into DemoTable(Value) values('X'); mysql> insert into DemoTable(Value) values('X'); mysql> insert into DemoTable(Value) values('Y'); mysql> insert ... 阅读更多
136 次浏览
要设置类型过滤器,可以使用以下语法:SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE = 'yourDataTypeName'; 让我们实现上述语法以仅显示字段类型为文本的字段:mysql> SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE = 'text'; 这将产生以下输出:+---------------------------------------------+--------------------------------+ | TABLE_NAME | COLUMN_NAME | +---------------------------------------------+--------------------------------+ | COLUMNS | ... 阅读更多
1K+ 次浏览
要按组列出所有行,可以使用 GROUP_CONCAT()。让我们先创建一个表:mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(20), Value varchar(100) ); 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable(Name, Value) values('John', 'John'); mysql> insert into DemoTable(Name, Value) values('Carol', 'Carol'); mysql> insert into DemoTable(Name, Value) values('John', 'Works'); mysql> insert ... 阅读更多
234 次浏览
您可以借助 CAST() 函数实现此目的。让我们先创建一个表:mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Score int ); 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable(Score) values(10); mysql> insert into DemoTable(Score) values(100); mysql> insert into DemoTable(Score) values(11); mysql> insert into DemoTable(Score) values(97); mysql> insert into DemoTable(Score) values(78); mysql> insert into DemoTable(Score) values(89); 使用 select 语句显示表中的所有记录:mysql> select * from DemoTable; 这将产生以下输出:+----+-------+ | Id | Score | +----+-------+ | 1 | 10 | ... 阅读更多
493 次浏览
使用正则表达式和 CASE 语句。让我们先创建一个表:mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value varchar(20) ); 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable(Value) values('101'); mysql> insert into DemoTable(Value) values('P'); mysql> insert into DemoTable(Value) values('A'); mysql> insert into DemoTable(Value) values('53'); mysql> ... 阅读更多
542 次浏览
要选择特定行,请在MySQL中使用FIND_IN_SET()函数。让我们先创建一个表 −mysql> create table DemoTable ( ListOfValues varchar(200) ); Query OK, 0 rows affected (0.31 sec)使用insert命令在表中插入一些记录 −mysql> insert into DemoTable values('112, 114, 567, Java, 345'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable values('222, 214, 256'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable values('2, 567, 98, C'); Query OK, 1 row affected (0.06 sec)使用select语句显示表中的所有记录 −mysql> select *from DemoTable; 这... 阅读更多
2K+ 次浏览
要根据多个列进行过滤,请使用where子句和OR一起使用。让我们先创建一个表 −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(10), Score int ); Query OK, 0 rows affected (0.28 sec)使用insert命令在表中插入一些记录 −mysql> insert into DemoTable(Name, Score) values('John', 80); Query OK, 1 row affected (0.04 sec) mysql> insert into DemoTable(Name, Score) values('John', 90); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable(Name, Score) values('Carol', 89); Query OK, 1 row affected (0.04 sec) ... 阅读更多