找到 4219 篇文章 关于 MySQLi
454 次查看
让我们先创建一个表 - mysql> create table DemoTable( Value int ); Query OK, 0 rows affected (1.35 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable values(NULL); Query OK, 1 row affected (0.29 sec) mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.59 sec) mysql> insert into DemoTable values(0); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.70 ... 阅读更多
105 次查看
SELECT * 比列出 40 列慢。使用 SELECT 查询时,最好列出列名。让我们看一个简单的例子,并创建一个表 - mysql> create table DemoTable( Id int, Name varchar(20), Age int, ZipCode varchar(20), CountryName varchar(20) ); Query OK, 0 rows affected (0.82 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values(101, 'Chris', 23, '0909332', 'US'); Query OK, 1 row affected (0.48 sec) mysql> insert into DemoTable values(102, 'Bob', 24, '8747443', 'AUS'); Query OK, 1 row affected (0.50 sec) ... 阅读更多
274 次查看
让我们先创建一个表 - mysql> create table DemoTable( Marks int ); Query OK, 0 rows affected (1.34 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values(78); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(88); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(67); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(76); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable values(98); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(86); Query OK, 1 row affected (0.11 ... 阅读更多
173 次查看
让我们先创建一个表 - mysql> create table DemoTable( Data int ); Query OK, 0 rows affected (0.98 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values(60); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable values(40); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(50); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(60); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(40); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(80); Query OK, 1 row affected (0.15 ... 阅读更多
173 次查看
让我们先创建一个表 - mysql> create table DemoTable1( Value int ); Query OK, 0 rows affected (0.65 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable1 values(67); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1 values(46); Query OK, 1 row affected (0.11 sec) 使用 select 语句显示表中的所有记录 - mysql> select *from DemoTable1; 这将产生以下输出 - +-------+ | Value | +-------+ | 67 | | 46 | +-------+ 2 rows in set (0.00 sec) 以下是如何创建... 阅读更多
96 次查看
让我们先创建一个带有 ENUM 类型列的表 - mysql> create table DemoTable( isMarried ENUM('1', '0') ); Query OK, 0 rows affected (0.46 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('0'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable values('1'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('1'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('0'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('0'); Query OK, 1 row affected (1.00 sec) mysql> insert into DemoTable values('1'); Query ... 阅读更多
265 次查看
为此,使用 ORDER BY FIELD()。让我们先创建一个表 - mysql> create table DemoTable( ClientId varchar(40), ClientName varchar(40) ); Query OK, 0 rows affected (0.55 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('987_John', 'John'); Query OK, 1 row affected (0.33 sec) mysql> insert into DemoTable values('1000_Sam', 'Sam'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values('777_Carol', 'Carol'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('2000_Bob', 'Bob'); Query OK, 1 row affected (0.20 sec) 使用 select 语句显示表中的所有记录 - mysql> select ... 阅读更多
117 次查看
让我们先创建一个表 - mysql> create table DemoTable( ArrivalDate timestamp ); Query OK, 0 rows affected (1.96 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('2019-09-14 17:25:00'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values('2019-09-13 17:25:00'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('2016-09-01 17:20:10'); Query OK, 1 row affected (0.38 sec) mysql> insert into DemoTable values('2019-09-11 12:00:00'); Query OK, 1 row affected (0.16 sec) 使用 select 语句显示表中的所有记录 - mysql> select *from DemoTable; 这将产生以下输出 - +---------------------+ | ... 阅读更多
120 次查看
让我们先创建一个表 - mysql> create table DemoTable ( StudentId int, StudentFirstName varchar(100), StudentLastName varchar(100) ); Query OK, 0 rows affected (0.54 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values(1000, 'Adam', 'Smith'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(1000, 'John', 'Doe'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(1000, 'David', 'Miller'); Query OK, 1 row affected (0.12 sec) 使用 select 语句显示表中的所有记录 - mysql> select *from DemoTable; 这将产生以下输出 - +-----------+------------------+-----------------+ | StudentId | StudentFirstName ... 阅读更多
405 次查看
为此,请结合使用 SUM() 和 GROUP BY。让我们先创建一个表 - mysql> create table DemoTable ( CustomerName varchar(100), Product_1_Price int, Product_2_Price int ); Query OK, 0 rows affected (0.73 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('John', 67, 89); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('David', 769, 890); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('David', 987, 1000); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('John', 900, 111); Query OK, 1 row affected (0.12 sec) 显示 ... 阅读更多