找到 4219 篇文章 关于 MySQLi
1K+ 浏览量
您可以为此使用聚合函数 MAX() 和 MIN()。让我们首先创建一个表 -mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Number1 int, Number2 int ); Query OK, 0 rows affected (0.89 sec)使用 insert 命令在表中插入记录 -mysql> insert into DemoTable(Number1, Number2) values(67, 45); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(Number1, Number2) values(90, 40); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(Number1, Number2) values(80, 43); Query OK, 1 row affected (0.48 sec)使用 select ... 阅读更多
146 浏览量
要修改现有列的数据类型,您可以使用 MODIFY。让我们首先创建一个表 -mysql> create table DemoTable ( ClientId varchar(100), ClientName varchar(100), ClientAge int, ClientProjectDeadline timestamp, ClientCountryName varchar(100), isMarried boolean, ClientNumber bigint ); Query OK, 0 rows affected (0.70 sec)检查表的描述 -mysql> desc DemoTable;这将产生以下输出 -+-----------------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------------+--------------+------+-----+---------+-------+ | ClientId ... 阅读更多
107 浏览量
您可以使用 UPDATE 与 DATE_ADD() 来更新所有日期。让我们首先创建一个表 -mysql> create table DemoTable ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientProjectDueDate date ); Query OK, 0 rows affected (1.19 sec)使用 insert 命令在表中插入记录 -mysql> insert into DemoTable(ClientProjectDueDate) values('2018-01-21'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(ClientProjectDueDate) values('2019-03-25'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(ClientProjectDueDate) values('2013-11-01'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(ClientProjectDueDate) values('2015-06-14'); Query OK, 1 row affected (0.23 sec)显示所有记录 ... 阅读更多
131 浏览量
您可以为此使用 CASE 语句。让我们首先创建一个表 -mysql> create table DemoTable ( Number int ); Query OK, 0 rows affected (0.71 sec)使用 insert 命令在表中插入记录 -mysql> insert into DemoTable values(490); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable values(310); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(540); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(123); Query OK, 1 row affected (0.60 sec) mysql> insert into DemoTable values(1230); Query OK, 1 row affected (0.15 sec) mysql> ... 阅读更多
932 浏览量
您可以为此使用 COUNT(*) 以及 GROUP BY。让我们首先创建一个表 -mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentAge int ); Query OK, 0 rows affected (0.59 sec)使用 insert 命令在表中插入记录 -mysql> insert into DemoTable(StudentAge) values(16); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(StudentAge) values(17); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(StudentAge) values(18); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(StudentAge) values(17); Query OK, 1 row affected (0.13 sec) mysql> insert into ... 阅读更多
120 浏览量
让我们首先创建一个表 -mysql> create table DemoTable ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(30) ); Query OK, 0 rows affected (0.74 sec)使用 insert 命令在表中插入记录 -mysql> insert into DemoTable(ClientName) values('John'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(ClientName) values('Chris'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(ClientName) values('Robert'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(ClientName) values('David'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(ClientName) values('Bob'); Query OK, 1 row affected (0.15 sec) mysql> ... 阅读更多
280 浏览量
您可以使用 STR_TO_DATE() 函数。让我们首先创建一个表 -mysql> create table DemoTable ( AdmissionDate varchar(200) ); Query OK, 0 rows affected (1.19 sec)使用 insert 命令在表中插入记录 -mysql> insert into DemoTable values('12-01-2019'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('14-12-2016'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('26-04-2018'); Query OK, 1 row affected (0.34 sec) mysql> insert into DemoTable values('31-05-2013'); Query OK, 1 row affected (0.30 sec)使用 select 语句显示表中的所有记录 -mysql> select * from DemoTable;这将产生 ... 阅读更多
94K+ 浏览量
要创建一个只有日期列的表,您可以使用 DATE 类型。让我们首先创建一个表 -mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(20), StudentAdmissionDate DATE ); Query OK, 0 rows affected (0.47 sec)使用 INSERT 命令在表中插入记录 -mysql> insert into DemoTable(StudentName, StudentAdmissionDate) values('Chris', now()); Query OK, 1 row affected, 1 warning (0.12 sec) mysql> insert into DemoTable(StudentName, StudentAdmissionDate) values('Robert', curdate()); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(StudentName, StudentAdmissionDate) values('David', '2019-05-21'); Query OK, 1 row affected (0.16 sec)显示所有 ... 阅读更多
11K+ 浏览量
您可以使用 ORDER BY 子句或聚合函数 MAX() 来选择最大值。使用 ORDER BY以下语法 -select yourColumnName from yourTableName order by yourColumnName desc limit 0, 1;让我们首先创建一个表 -mysql> create table DemoTable ( Number int ); Query OK, 0 rows affected (0.52 sec)使用 insert 命令在表中插入记录 -mysql> insert into DemoTable values(790); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(746); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(480); Query OK, 1 row affected (0.15 sec) mysql> insert into ... 阅读更多
219 浏览量
您可以为此使用 CASE 语句。让我们首先创建一个表 -mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(20) ); Query OK, 0 rows affected (1.11 sec)使用 insert 命令在表中插入记录 -mysql> insert into DemoTable(Name) values('John'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable(Name) values('Carol'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(Name) values('David'); Query OK, 1 row affected (0.13 sec)使用 select 语句显示表中的所有记录 -mysql> select * from DemoTable;这将产生以下 ... 阅读更多