找到 4219 篇文章 适用于 MySQLi
131 次查看
使用 MySQL BETWEEN 获取不同值之间的值。让我们首先创建一个表 -mysql> create table DemoTable1473 -> ( -> EmployeeCode varchar(20) -> ); Query OK, 0 rows affected (0.47 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1473 values('EMP_120'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable1473 values('EMP_125'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1473 values('EMP_30'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1473 values('EMP_130'); Query OK, 1 row affected (0.10 sec)使用 select ... 阅读更多
287 次查看
让我们首先创建一个表。在这里,我们已将日期声明为 char 类型 -mysql> create table DemoTable1472 -> ( -> ShippingDate char(35) -> ); Query OK, 0 rows affected (0.46 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1472 values('12/31/2017 10:50'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1472 values('01/10/2018 12:00'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1472 values('03/20/2019 09:30'); Query OK, 1 row affected (0.14 sec)使用 select 语句显示表中的所有记录 -mysql> select * from DemoTable1472;这将产生以下输出 ... 阅读更多
340 次查看
让我们首先创建一个表 -mysql> create table DemoTable1471 -> ( -> EmployeeJoiningDate date, -> EmployeeRelievingDate date -> ); Query OK, 0 rows affected (0.57 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1471 values('2018-06-21', '2018-12-21'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1471 values('2017-01-19', '2019-01-31'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1471 values('2015-12-31', '2016-03-01'); Query OK, 1 row affected (0.11 sec)使用 select 语句显示表中的所有记录 -mysql> select * from DemoTable1471;这将产生以下输出 -+---------------------+-----------------------+ | EmployeeJoiningDate | ... 阅读更多
107 次查看
为此,使用 COALESCE()。让我们首先创建一个表 -mysql> create table DemoTable1470 -> ( -> FirstName varchar(20), -> Age int -> ); Query OK, 0 rows affected (0.57 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1470 values('Robert', 23); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1470 values('Bob', NULL); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1470 values(NULL, 25); Query OK, 1 row affected (0.15 sec)使用 select 语句显示表中的所有记录 -mysql> select * from DemoTable1470;这将产生以下输出 ... 阅读更多
464 次查看
要从 MySQL 表中删除索引,语法如下 -alter table yourTableName drop index `yourIndexName`;让我们首先创建一个表 -Mysql> create table DemoTable1469 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(40), -> StudentAge int -> ); Query OK, 0 rows affected (0.78 sec)以下是在列名上添加索引的查询 -mysql> create index `Student Name_Index` on DemoTable1469(StudentName); Query OK, 0 rows affected (0.33 sec) Records: 0 Duplicates: 0 Warnings: 0让我们检查表描述 -mysql> desc DemoTable1469;这将产生以下输出 -+-------------+-------------+------+-----+---------+----------------+ ... 阅读更多
70 次查看
让我们首先创建一个表 -mysql> create table DemoTable1468 -> ( -> Id int, -> Name varchar(20), -> Age int -> ); Query OK, 0 rows affected (1.21 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1468 values(100, 'Chris', 23); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1468 values(101, 'Bob', 25); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1468 values(102, 'David', 30); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1468 values(100, 'Chris', 23); Query OK, 1 row affected (0.35 sec) mysql> ... 阅读更多
804 次查看
为此,您可以使用 GROUP BY HAVING 子句。让我们首先创建一个表 -mysql> create table DemoTable1467 -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.64 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1467 values(100, 'Chris'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1467 values(110, 'David'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1467 values(120, 'Mike'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1467 values(100, 'Chris'); Query OK, 1 row affected (0.12 sec) ... 阅读更多
524 次查看
不要为此使用以下查询 -insert into yourTableName values(yourValue1, yourValue2, ...N); insert into yourTableName values(yourValue1, yourValue2, ...N); insert into yourTableName values(yourValue1, yourValue2, ...N); . . . N您可以使用以下查询作为在单个查询中插入多个值的最快方法 -insert into yourTableName values(yourValue1, yourValue2, ...N), (yourValue1, yourValue2, ...N), (yourValue1, yourValue2, ...N), ...................N;让我们首先创建一个表 -mysql> create table DemoTable1466 -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20), -> Age int -> ); Query OK, 0 rows affected (0.98 sec)插入一些记录 ... 阅读更多
192 次查看
让我们首先创建一个表 -mysql> create table DemoTable1465 -> ( -> Name varchar(40) -> ); Query OK, 0 rows affected (0.54 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1465 values('Chris Brown'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1465 values('David Miller'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable1465 values('John Doe'); Query OK, 1 row affected (0.14 sec)使用 select 语句显示表中的所有记录 -mysql> select * from DemoTable1465;这将产生以下输出 -+--------------+ | Name | ... 阅读更多
2K+ 次查看
您可以使用存储过程,并通过参数传递值。让我们首先创建一个表 -mysql> create table DemoTable1464 -> ( -> Id int, -> FirstName varchar(20) -> ); Query OK, 0 rows affected (0.51 sec)使用insert命令在表中插入一些记录 -mysql> insert into DemoTable1464 values(101, 'Chris Brown'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1464 values(102, 'John Doe'); Query OK, 1 row affected (0.09 sec)使用select语句显示表中的所有记录 -mysql> select * from DemoTable1464;这将产生以下输出 -+------+-------------+ | Id ... 阅读更多