找到 4379 篇文章 关于 MySQL
108 次浏览
为此,使用 substring_index() 方法。 让我们首先创建一个表 -mysql> create table DemoTable -> ( -> FolderName varchar(100), -> FolderLocation varchar(200) -> ); Query OK, 0 rows affected (1.03 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('CProgram', 'C:/AllPrograms/.....'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Images', 'E:/MyImage/home/garbage'); Query OK, 1 row affected (0.15 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable;Output+------------+-------------------------+ | FolderName | FolderLocation | +------------+-------------------------+ | CProgram | C:/AllPrograms/..... ... 阅读更多
119 次浏览
您可以使用 MySQL 的 DATE_ADD() 函数。 让我们首先创建一个表 -mysql> create table DemoTable -> ( -> ShippingDate varchar(100) -> ); Query OK, 0 rows affected (0.67 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('06-01-2019'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('01-04-2017'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('29-06-2019'); Query OK, 1 row affected (0.47 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable;Output+--------------+ | ShippingDate | +--------------+ | 06-01-2019 | ... 阅读更多
117 次浏览
让我们首先创建一个表 -mysql> create table DemoTable -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentScore varchar(100) -> ); Query OK, 0 rows affected (0.66 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable(StudentScore) values('90'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(StudentScore) values('100'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(StudentScore) values('56'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(StudentScore) values('98'); Query OK, 1 row affected (0.13 sec)显示表中的所有记录 ... 阅读更多
237 次浏览
让我们首先创建一个表 -mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(100), -> Age int -> ); Query OK, 0 rows affected (0.49 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable(Name, Age) values('Robert', 24); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(Name, Age) values('Chris', 22); Query OK, 1 row affected (0.13 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable;Output+----+--------+------+ | Id | Name | Age | +----+--------+------+ ... 阅读更多
102 次浏览
让我们首先创建一个表 -mysql> create table DemoTable -> ( -> Name varchar(100), -> DueDate datetime -> ); Query OK, 0 rows affected (0.54 sec)使用 insert 命令在表中插入一些记录。 假设当前日期是“2019-07-05” -mysql> insert into DemoTable values('Chris', '2019-06-24'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('Chris', '2018-01-01'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Robert', '2019-07-05'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('Carol', '2019-08-03'); Query OK, 1 row affected (0.22 ... 阅读更多
231 次浏览
为此,使用 CONCAT() 函数连接日期和时间。 让我们首先创建一个表 -mysql> create table DemoTable -> ( -> ShippingDate date, -> ShippingTime time, -> ShippingDatetime datetime -> ); Query OK, 0 rows affected (0.50 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable(ShippingDate, ShippingTime) values('2019-01-10', '10:40:20'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(ShippingDate, ShippingTime) values('2019-06-14', '04:00:10'); Query OK, 1 row affected (0.14 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable;Output+--------------+--------------+------------------+ | ShippingDate | ShippingTime | ... 阅读更多
165 次浏览
让我们首先创建一个表 -mysql> create table DemoTable1 -> ( -> StudentId int, -> StudentName varchar(20) -> ); Query OK, 0 rows affected (0.64 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1 values(10, 'John'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1 values(11, 'Chris'); Query OK, 1 row affected (0.15 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable1;Output+-----------+-------------+ | StudentId | StudentName | +-----------+-------------+ | 10 | John ... 阅读更多
228 次浏览
让我们首先创建一个表 -mysql> create table DemoTable -> ( -> ShippingDate datetime -> ); Query OK, 0 rows affected (0.52 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('2019-01-10 10:04:45'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('2019-06-11 05:45:00'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values('2019-06-12 07:00:55'); Query OK, 1 row affected (0.14 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable;Output+---------------------+ | ShippingDate | +---------------------+ | 2019-01-10 10:04:45 | | 2019-06-11 05:45:00 | | 2019-06-12 07:00:55 | +---------------------+ 3 rows in set (0.00 sec)以下是获取 MySQL 中分钟的查询 -mysql> select minute(ShippingDate) as Minutes from DemoTable;Output+---------+ | Minutes | +---------+ | 4 ... 阅读更多
202 次浏览
为此使用 CASE 语句。 让我们首先创建一个表 -mysql> create table DemoTable -> ( -> StudentMarks int, -> isValid tinyint(1) -> ); Query OK, 0 rows affected (0.68 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values(45, 0); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(78, 1); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values(45, 1); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable values(78, 1); Query OK, 1 row affected (0.22 sec) ... 阅读更多
228 次浏览
为此使用 GROUP BY 子句。 让我们首先创建一个表 -mysql> create table DemoTable -> ( -> StudentId int, -> StudentMarks int -> ); Query OK, 0 rows affected (4.71 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values(23, 58); Query OK, 1 row affected (0.70 sec) mysql> insert into DemoTable values(25, 89); Query OK, 1 row affected (0.46 sec) mysql> insert into DemoTable values(26, 58); Query OK, 1 row affected (1.13 sec) mysql> insert into DemoTable values(28, 98); Query OK, 1 row affected (0.86 sec)显示 ... 阅读更多