找到 4379 篇文章 关于 MySQL
272 次浏览
为此,在 MySQL 列上使用 UPPER()。让我们首先创建一个表 - mysql> create table DemoTable627 (Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(100)); Query OK, 0 rows affected (0.62 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable627(FirstName) values(UPPER('John')); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable627(FirstName) values(UPPER('Sam')); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable627(FirstName) values(UPPER('Mike')); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable627(FirstName) values(UPPER('Carol')); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable627(FirstName) values(UPPER('dAVID')); Query OK, 1 row affected (0.70 ... 阅读更多
119 次浏览
为此,使用 ZEROFILL 概念。它将字段的显示值用零填充,直到达到列定义中设置的显示宽度。让我们首先创建一个表 - mysql> create table DemoTable626 (Value int(5) zerofill); Query OK, 0 rows affected (0.71 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable626 values(9); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable626 values(12); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable626 values(567); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable626 values(3478); Query OK, 1 row affected ... 阅读更多
239 次浏览
让我们首先创建一个表 - mysql> create table DemoTable625 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(100), StudentScore int ); Query OK, 0 rows affected (1.01 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable625(StudentFirstName, StudentScore) values('John', 98); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable625(StudentFirstName, StudentScore) values('Chris', 39); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable625(StudentFirstName, StudentScore) values('Bob', 41); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable625(StudentFirstName, StudentScore) values('David', 40); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable625(StudentFirstName, StudentScore) ... 阅读更多
689 次浏览
为此,您可以使用 time_format() 和 time_diff()。要查找时间差,您需要使用 time_diff() 方法。让我们首先创建一个表 - mysql> create table DemoTable624 (PunchIn datetime, PunchOut datetime); Query OK, 0 rows affected (0.60 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable624 values('2019-07-14 12:10:00', '2019-07-14 12:50:00'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable624 values('2019-07-14 11:00:00', '2019-07-14 11:30:00'); Query OK, 1 row affected (0.34 sec) 使用 select 语句显示表中的所有记录 - mysql> select *from DemoTable624; 这将产生以下输出 - +---------------------+---------------------+ | PunchIn ... 阅读更多
333 次浏览
让我们首先创建一个表 - mysql> create table DemoTable623 (FirstName varchar(100), LastName varchar(100), Age int); Query OK, 0 rows affected (0.76 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable623 values('John', 'Smith', 23); Query OK, 1 row affected (0.66 sec) mysql> insert into DemoTable623 values('Adam', 'smith', 23); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable623 values('Chris', 'Brown', 24); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable623 values('Robert', 'brown', 21); Query OK, 1 row affected (0.22 sec) 使用 select 语句显示表中的所有记录 - mysql> select *from DemoTable623; 这将 ... 阅读更多
353 次浏览
让我们首先创建一个表 - mysql> create table DemoTable622 (Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value1 int, Value2 int); Query OK, 0 rows affected (1.08 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable622(Value1, Value2) values(1000, 1000); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable622(Value1, Value2) values(2000, 3000); Query OK, 1 row affected (1.04 sec) 使用 select 语句显示表中的所有记录 - mysql> select *from DemoTable622; 这将产生以下输出 - +----+--------+--------+ | Id | Value1 | Value2 | +----+--------+--------+ | 1 | 1000 | 1000 ... 阅读更多
75 次浏览
让我们首先创建一个表 - mysql> create table DemoTable621 (UserName varchar(100), UserEmailId varchar(100), UserLastPost datetime); Query OK, 0 rows affected (0.59 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable621 values('John', '[email protected]', '2019-04-10 11:01:10'); Query OK, 1 row affected (0.47 sec) mysql> insert into DemoTable621 values('John', '[email protected]', '2019-07-14 13:07:10'); Query OK, 1 row affected (0.15 sec) 使用 select 语句显示表中的所有记录 - mysql> select *from DemoTable621; 这将产生以下输出 - +----------+----------------+---------------------+ | UserName | UserEmailId | UserLastPost | +----------+----------------+---------------------+ | John | ... 阅读更多
450 次浏览
为此,您可以使用 INFORMATION_SCHEMA。以下是语法 - select my_schema.SCHEMA_NAME, group_concat(tbl.TABLE_NAME) from information_schema.SCHEMATA my_schema left join information_schema.TABLES tbl on my_schema.SCHEMA_NAME=tbl.TABLE_SCHEMA group by my_schema.SCHEMA_NAME; 让我们实现上述语法,以显示 MySQL 中的所有数据库以及每个数据库 - mysql> select my_schema.SCHEMA_NAME, group_concat(tbl.TABLE_NAME) from information_schema.SCHEMATA my_schema left join information_schema.TABLES tbl on my_schema.SCHEMA_NAME=tbl.TABLE_SCHEMA group by my_schema.SCHEMA_NAME; 这将产生以下输出 - +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | SCHEMA_NAME | group_concat(tbl.TABLE_NAME) ... 阅读更多
浏览量:378
为此,您可以使用INSERT INTO…SELECT语句。让我们先创建一个表:mysql> create table DemoTabe1 (Marks int); Query OK, 0 rows affected (0.66 sec)使用insert命令在表中插入一些记录:mysql> insert into DemoTabe1 values(68); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTabe1 values(89); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTabe1 values(99); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTabe1 values(39); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTabe1 values(49); Query OK, 1 row affected (0.12 sec)显示表中的所有记录... 阅读更多