找到 4219 篇文章 关于 MySQLi
167 次查看
让我们创建一个表 -mysql> create table DemoTable1996 ( ShippingDate datetime, CustomerName varchar(20) ); Query OK, 0 rows affected (0.84 sec)插入一些记录到表中使用 insert 命令 -mysql> insert into DemoTable1996 values('2019-12-21 10:45:00', 'Chris'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1996 values('2019-12-21 12:10:00', 'David'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1996 values('2019-12-20 12:10:00', 'Bob'); Query OK, 1 row affected (0.14 sec)使用 select 语句显示表中的所有记录 -mysql> select * from DemoTable1996;这将产生以下输出 -+---------------------+--------------+ | ShippingDate | CustomerName ... 阅读更多
364 次查看
让我们首先创建一个表 -mysql> create table DemoTable1994 ( ArrivalDate date ); Query OK, 0 rows affected (5.33 sec)插入一些记录到表中使用 insert 命令 -mysql> insert into DemoTable1994 values('2019-12-18'); Query OK, 1 row affected (0.47 sec) mysql> insert into DemoTable1994 values('2019-12-19'); Query OK, 1 row affected (0.33 sec) mysql> insert into DemoTable1994 values('2019-12-20'); Query OK, 1 row affected (0.49 sec) mysql> insert into DemoTable1994 values('2019-12-25'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable1994 values('2018-12-20'); Query OK, 1 row affected (1.42 sec)使用 select 语句显示表中的所有记录 -mysql> select ... 阅读更多
134 次查看
使用 if else 为枚举设置自定义消息。让我们首先创建一个表 -mysql> create table DemoTable1992 ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(20), isActive ENUM('Y', 'N') ); Query OK, 0 rows affected (0.89 sec)插入一些记录到表中使用 insert 命令 -mysql> insert into DemoTable1992(ClientName, isActive) values('Chris', 'N'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1992(ClientName, isActive) values('Bob', 'N'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable1992(ClientName, isActive) values('David', 'Y'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1992(ClientName, isActive) values('Carol', ... 阅读更多
714 次查看
为此,您可以使用 NOT IN() -mysql> create table DemoTable1991 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(20) ); Query OK, 0 rows affected (0.61 sec)插入一些记录到表中使用 insert 命令 -mysql> insert into DemoTable1991(StudentName) values('Chris'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable1991(StudentName) values('Bob'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1991(StudentName) values('David'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable1991(StudentName) values('Sam'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1991(StudentName) values('Mike'); Query OK, 1 row affected (0.11 sec)显示所有 ... 阅读更多
270 次查看
要获取从今天开始一周后的日期,请使用 DATEDIFF。让我们首先获取当前日期 -mysql> select curdate(); +------------+ | curdate() | +------------+ | 2019-12-20 | +------------+ 1 row in set (0.00 sec)我们将首先创建一个表 -mysql> create table DemoTable1990 ( ShippingDate date ); Query OK, 0 rows affected (0.99 sec)插入一些记录到表中使用 insert 命令 -mysql> insert into DemoTable1990 values('2019-12-13'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1990 values('2019-12-21'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1990 values('2019-12-20'); Query OK, 1 ... 阅读更多
618 次查看
要将 VARCHAR 数据转换为日期格式,您可以使用 STR_TO_DATE() -mysql> create table DemoTable1989 ( DueDate varchar(20) ); Query OK, 0 rows affected (0.91 sec)插入一些记录到表中使用 insert 命令 -mysql> insert into DemoTable1989 values('31/01/2015'); Query OK, 1 row affected (0.52 sec) mysql> insert into DemoTable1989 values('01/12/2018'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1989 values('25/10/2019'); Query OK, 1 row affected (0.11 sec)使用 select 语句显示表中的所有记录 -mysql> select * from DemoTable1989;这将产生以下输出 -+------------+ | DueDate | +------------+ | 31/01/2015 | ... 阅读更多
430 次查看
您可以使用 CASE 语句 -mysql> create table DemoTable1988 ( Value1 int, Value2 int, Price int ); Query OK, 0 rows affected (0.64 sec)插入一些记录到表中使用 insert 命令 -mysql> insert into DemoTable1988 values(10, 7, 500); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1988 values(7, 9, 400); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1988 values(8, 7, 200); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1988 values(7, 4, 300); Query OK, 1 row affected (0.16 sec)显示表中的所有记录使用 select ... 阅读更多
170 次查看
要仅返回月份编号,您可以使用 DATE_FORMAT() -mysql> create table DemoTable1999 ( ArrivalDate timestamp ); Query OK, 0 rows affected (0.66 sec)插入一些记录到表中使用 insert 命令 -mysql> insert into DemoTable1999 values('2019-01-01 12:34:00'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1999 values('2019-12-31 10:04:00'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1999 values('2018-10-11 04:04:30'); Query OK, 1 row affected (0.14 sec)使用 select 语句显示表中的所有记录 -mysql> select * from DemoTable1999;这将产生以下输出 -+---------------------+ | ArrivalDate ... 阅读更多
439 次查看
为此,您可以使用 UNION ALL。让我们首先创建一个表 -mysql> create table DemoTable1987 ( UserValue int ); Query OK, 0 rows affected (2.90 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1987 values(4); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable1987 values(5); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1987 values(6); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1987 values(7); Query OK, 1 row affected (0.09 sec)使用 select 语句显示表中的所有记录 -mysql> select * from DemoTable1987;这 ... 阅读更多
82 次浏览
为此,您可以使用 IN() 以及 ORDER BY 子句。让我们首先创建一个表 -mysql> create table DemoTable1986 ( Number int ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1986 values(50); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1986 values(60); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1986 values(100); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1986 values(200); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1986 values(350); Query OK, 1 row ... 阅读更多