找到关于 MySQLi 的4219 篇文章
162 次查看
假设当前日期是 2019-09-06。在本例中,我们将首先创建一个表:mysql> create table DemoTable ( AdmissionDate date ); Query OK, 0 rows affected (0.54 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('2019-01-08'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('2018-09-06'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('2016-10-26'); Query OK, 1 row affected (0.17 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable;这将产生以下输出:+---------------+ | AdmissionDate | +---------------+ | 2019-01-08 ... 阅读更多
770 次查看
让我们首先创建一个表:mysql> create table DemoTable ( Code varchar(100) ); Query OK, 0 rows affected (0.50 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('8565-9848-7474'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('9994-6464-8737'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('6574-9090-7643'); Query OK, 1 row affected (0.17 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable;这将产生以下输出:+----------------+ | Code | +----------------+ | 8565-9848-7474 | | 9994-6464-8737 | | ... 阅读更多
530 次查看
要转换,请使用 JSON.stringify()。以下是将 MySQL DATETIME 值转换为 JavaScript 中 JSON 格式的代码:var mySQLDateTime = new Date("Fri Sep 06 2019 22 −54 −48 "); var yearValue = mySQLDateTime.getFullYear(); var dateValue = mySQLDateTime.getDate(); var monthValue=mySQLDateTime.getMonth(); var hour=mySQLDateTime.getHours(); var minutes=mySQLDateTime.getMinutes(); var second=mySQLDateTime.getSeconds(); jsonObject={"year" −yearValue,"month" :monthValue,"DateValue" :dateValue,"Hour" :hour ,"Minutes" :minutes,"Second" :second}; var dateJsonObject = JSON.stringify(jsonObject); document.write(dateJsonObject); 代码截图如下:这将产生以下输出:{"year" :2019,"month" :8,"DateValue" :6,"Hour" :22,"Minutes" :54,"Second" :48}输出截图如下:
1K+ 次查看
对于特定月份,使用 MONTH();对于年份,使用 YEAR() 方法。让我们首先创建一个表:mysql> create table DemoTable ( StudentName varchar(40), StudentAdmissionDate date ); Query OK, 0 rows affected (0.67 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('Chris', '2019-01-21'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Robert', '2018-09-05'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('Mike', '2019-09-05'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable values('David', '2019-10-04'); Query OK, 1 row affected (0.14 sec)显示表中的所有记录: ... 阅读更多
403 次查看
让我们首先创建一个表:mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, EmployeeSalary int ); Query OK, 0 rows affected (1.68 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable(EmployeeSalary) values(12000); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable(EmployeeSalary) values(20000); Query OK, 1 row affected (0.55 sec) mysql> insert into DemoTable(EmployeeSalary) values(11500); Query OK, 1 row affected (0.94 sec) mysql> insert into DemoTable(EmployeeSalary) values(15500); Query OK, 1 row affected (0.44 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable;这将产生 ... 阅读更多
259 次查看
假设当前日期是 2019-08-20。现在,在本例中,我们将创建一个表:mysql> create table DemoTable ( ProductStatus tinyint(1), ProductExpiryDate date ); Query OK, 0 rows affected (1.03 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values(0, '2019-06-12'); Query OK, 1 row affected (0.43 sec) mysql> insert into DemoTable values(0, '2019-10-11'); Query OK, 1 row affected (0.38 sec) mysql> insert into DemoTable values(0, '2018-07-24'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(0, '2018-09-05'); Query OK, 1 row affected (0.27 sec)显示表中的所有记录: ... 阅读更多
70 次查看
使用 GROUP BY 对记录进行分组,而 SUM() 函数用于求和。让我们首先创建一个表:mysql> create table DemoTable ( Name varchar(40), Subject varchar(40), Marks int ); Query OK, 0 rows affected (2.89 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('Chris', 'MySQL', 76); Query OK, 1 row affected (0.32 sec) mysql> insert into DemoTable values('Sam', 'MongoDB', 86); Query OK, 1 row affected (0.39 sec) mysql> insert into DemoTable values('Mike', 'MySQL', 98); Query OK, 1 row affected (0.46 sec) mysql> insert into DemoTable values('David', 'Java', 93); Query OK, ... 阅读更多
566 次查看
使用变量存储 SUM(total),并使用 UPDATE 命令更新它。让我们首先创建一个表:mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value int ); Query OK, 0 rows affected (0.61 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable(Value) values(70); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(Value) values(100); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(Value) values(150); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(Value) values(250); Query OK, 1 row affected (0.14 sec) mysql> ... 阅读更多
148 次查看
让我们首先创建一个表:mysql> create table DemoTable ( CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ProductAmount int ); Query OK, 0 rows affected (0.61 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable(ProductAmount) values(5000); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(ProductAmount) values(6000); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable(ProductAmount) values(7000); Query OK, 1 row affected (0.26 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable;这将产生以下输出:+------------+---------------+ | CustomerId | ProductAmount | +------------+---------------+ | ... 阅读更多
342 次查看
让我们首先创建一个表:mysql> create table DemoTable1 ( Name varchar(40) ); Query OK, 0 rows affected (0.81 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable1 values('Chris'); Query OK, 1 row affected (0.48 sec) mysql> insert into DemoTable1 values('Robert'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1 values('Mike'); Query OK, 1 row affected (0.10 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable1;这将产生以下输出:+--------+ | Name | +--------+ | Chris | | Robert | | Mike | +--------+ ... 阅读更多