找到 4219 篇文章 关于 MySQLi
505 次浏览
让我们先创建一个表 −mysql> create table DemoTable1496 -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> PassengerCode varchar(20), -> ArrivalDate datetime -> ); Query OK, 0 rows affected (0.85 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable1496(PassengerCode, ArrivalDate) values('202', '2013-03-12 10:12:34'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable1496(PassengerCode, ArrivalDate) values('202_John', '2013-03-12 11:00:00'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1496(PassengerCode, ArrivalDate) values('204', '2013-03-12 10:12:34'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1496(PassengerCode, ArrivalDate) values('208', '2013-03-14 ... 阅读更多
239 次浏览
让我们先创建一个表 −mysql> create table DemoTable1495 -> ( -> ShippingDate bigint -> ); Query OK, 0 rows affected (0.63 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable1495 values(1570127400); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1495 values(1570213800); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1495 values(1570645800); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1495 values(1570300200); Query OK, 1 row affected (0.15 sec)使用 select 语句显示表中的所有记录 −mysql> select * from DemoTable1495;这将产生以下 ... 阅读更多
286 次浏览
为此,使用 DECIMAL(21,20)。让我们先创建一个表 −mysql> create table DemoTable1493 -> ( -> LongValue DECIMAL(21,20) -> ); Query OK, 0 rows affected (0.48 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable1493 values(1.0047464644664677373); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1493 values(5.999999484757773); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1493 values(0.009994995885885); Query OK, 1 row affected (0.21 sec)使用 select 语句显示表中的所有记录 −mysql> select * from DemoTable1493;这将产生以下输出 −+------------------------+ | LongValue | +------------------------+ | 1.00474646446646773730 | | 5.99999948475777300000 | | 0.00999499588588500000 | +------------------------+ 3 rows in set (0.00 sec)
3K+ 次浏览
如果您使用了不正确的语法,可能会发生此错误。假设以下为 create table 语句 −mysql> create table DemoTable1492 -> ( -> timestamp TIMESTAMP, -> event int, -> ); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 5您需要删除上面 event 列后面的额外逗号才能修复。让我们首先创建一个 −mysql> create table DemoTable1492 -> ( -> timestamp TIMESTAMP, ... 阅读更多
111 次浏览
为了在 MySQL 数据库中存储 PayPal 十进制金额,您可以使用 DECIMAL(10, 2)。让我们先创建一个表 −mysql> create table DemoTable1491 -> ( -> Amount DECIMAL(10, 2) -> ); Query OK, 0 rows affected (0.66 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable1491 values(987664.50); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1491 values(18783874.90); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1491 values(35363738.50); Query OK, 1 row affected (0.15 sec)使用 select 语句显示表中的所有记录 −mysql> select * from ... 阅读更多
360 次浏览
为此,使用 AVG() 求平均值,并使用 GROUP BY 对重复列 (Product Id) 的记录进行分组。让我们先创建一个表 −mysql> create table DemoTable1490 -> ( -> ProductId varchar(20), -> ProductPrice int -> ); Query OK, 0 rows affected (0.43 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable1490 values('PRODUCT_100', 700); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1490 values('PRODUCT_200', 500); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable1490 values('PRODUCT_200', 1000); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1490 values('PRODUCT_100', ... 阅读更多
255 次浏览
让我们先创建一个表 −mysql> create table DemoTable1489 -> ( -> ProductId int, -> ProductPrice int -> ); Query OK, 0 rows affected (0.49 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable1489 values(100, 900); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1489 values(115, 1000); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1489 values(119, 2100); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1489 values(125, 2100); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1489 values(128, 2900); Query OK, 1 ... 阅读更多
323 次浏览
MySQL EXPLAIN 提供查询执行计划。EXPLAIN 可以与 SELECT、INSERT、DELETE、REPLACE 和 UPDATE 一起使用。为了避免数据库中的完整表扫描,您需要使用索引。让我们先创建一个表 −mysql> create table DemoTable1488 -> ( -> StudentId int, -> StudentName varchar(20), -> StudentAge int -> ); Query OK, 0 rows affected (2.18 sec)这是创建索引的查询 −mysql> create index student_id_index on DemoTable1488(StudentId); Query OK, 0 rows affected (0.90 sec) Records: 0 Duplicates: 0 Warnings: 0insert into DemoTable1488 value在...中插入一些记录 阅读更多
84 次浏览
为此,您可以将 ORDER BY 与一些聚合函数 right() 一起使用。让我们先创建一个表 −mysql> create table DemoTable1487 -> ( -> StudentCode text -> ); Query OK, 0 rows affected (0.91 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable1487 values('560'); Query OK, 1 row affected (0.36 sec) mysql> insert into DemoTable1487 values('789'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1487 values('STUDENT78'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1487 values('John89'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1487 ... 阅读更多
543 次浏览
为此,您可以使用 ORDER BY 和 LIMIT。这里,LIMIT 用于设置要获取的记录数(计数)。让我们先创建一个表:
mysql> create table DemoTable1486
-> (
-> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
-> StudentName varchar(20)
-> );
Query OK, 0 rows affected (0.66 sec)
使用 insert 命令在表中插入一些记录:
mysql> insert into DemoTable1486(StudentName) values('Chris Brown');
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable1486(StudentName) values('David Miller');
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable1486(StudentName) values('John Doe'); ... 阅读更多