找到 4219 篇文章 关于 MySQLi
353 次浏览
让我们首先创建一个表:mysql> create table DemoTable622 (Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value1 int, Value2 int); Query OK, 0 rows affected (1.08 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable622(Value1, Value2) values(1000, 1000); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable622(Value1, Value2) values(2000, 3000); Query OK, 1 row affected (1.04 sec) 使用 select 语句显示表中的所有记录:mysql> select * from DemoTable622; 这将产生以下输出:+----+--------+--------+ | Id | Value1 | Value2 | +----+--------+--------+ | 1 | 1000 | 1000 ... 阅读更多
75 次浏览
让我们首先创建一个表:mysql> create table DemoTable621 (UserName varchar(100), UserEmailId varchar(100), UserLastPost datetime); Query OK, 0 rows affected (0.59 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable621 values('John', '[email protected]', '2019-04-10 11:01:10'); Query OK, 1 row affected (0.47 sec) mysql> insert into DemoTable621 values('John', '[email protected]', '2019-07-14 13:07:10'); Query OK, 1 row affected (0.15 sec) 使用 select 语句显示表中的所有记录:mysql> select * from DemoTable621; 这将产生以下输出:+----------+----------------+---------------------+ | UserName | UserEmailId | UserLastPost | +----------+----------------+---------------------+ | John | ... 阅读更多
450 次浏览
为此,您可以使用 INFORMATION_SCHEMA。以下是语法:select my_schema.SCHEMA_NAME, group_concat(tbl.TABLE_NAME) from information_schema.SCHEMATA my_schema left join information_schema.TABLES tbl on my_schema.SCHEMA_NAME=tbl.TABLE_SCHEMA group by my_schema.SCHEMA_NAME; 让我们实现上述语法以显示 MySQL 中的所有数据库和每个数据库:mysql> select my_schema.SCHEMA_NAME, group_concat(tbl.TABLE_NAME) from information_schema.SCHEMATA my_schema left join information_schema.TABLES tbl on my_schema.SCHEMA_NAME=tbl.TABLE_SCHEMA group by my_schema.SCHEMA_NAME; 这将产生以下输出:+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | SCHEMA_NAME | group_concat(tbl.TABLE_NAME) ... 阅读更多
378 次浏览
为此,您可以使用 INSERT INTO…SELECT 语句。让我们首先创建一个表:mysql> create table DemoTabe1 (Marks int); Query OK, 0 rows affected (0.66 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTabe1 values(68); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTabe1 values(89); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTabe1 values(99); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTabe1 values(39); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTabe1 values(49); Query OK, 1 row affected (0.12 sec) 显示表中的所有记录 ... 阅读更多
7K+ 次浏览
让我们首先创建一个表:mysql> create table DemoTable719 (FirstNumber int, SecondNumber int); Query OK, 0 rows affected (0.57 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable719 values(20, 10); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable719 values(500, 50); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable719 values(400, 20); Query OK, 1 row affected (0.11 sec) 使用 select 语句显示表中的所有记录:mysql> select * from DemoTable719; 这将产生以下输出:+-------------+--------------+ | FirstNumber | SecondNumber | +-------------+--------------+ | 20 | ... 阅读更多
83 次浏览
为此,您可以使用子查询。让我们首先创建一个表:mysql> create table DemoTable618 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(100) ); Query OK, 0 rows affected (1.45 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable618(StudentFirstName) values('David'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable618(StudentFirstName) values('Chris'); Query OK, 1 row affected (0.44 sec) mysql> insert into DemoTable618(StudentFirstName) values('Robert'); Query OK, 1 row affected (0.54 sec) mysql> insert into DemoTable618(StudentFirstName) values('Sam'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable618(StudentFirstName) values('Mike'); Query OK, 1 ... 阅读更多
382 次浏览
要跳过行,您可以使用 OFFSET。让我们首先创建一个表:mysql> create table DemoTable617(Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(100)); Query OK, 0 rows affected (1.70 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable617(FirstName) values('John'); Query OK, 1 row affected (0.39 sec) mysql> insert into DemoTable617(FirstName) values('Sam'); Query OK, 1 row affected (0.39 sec) mysql> insert into DemoTable617(FirstName) values('Carol'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable617(FirstName) values('Mike'); Query OK, 1 row affected (0.34 sec) mysql> insert into DemoTable617(FirstName) values('David'); Query OK, 1 row affected (0.17 sec) ... 阅读更多
177 次浏览
为此,您可以使用聚合函数 SUM()。让我们首先创建一个表:mysql> create table DemoTable616 (Price varchar(100)); Query OK, 0 rows affected (0.59 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable616 values('€200.00'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable616 values('€300.00'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable616 values('€500.00'); Query OK, 1 row affected (0.12 sec) 使用 select 语句显示表中的所有记录:mysql> select * from DemoTable616; 这将产生以下输出:+-----------+ | Price | +-----------+ | €200.00 | | ... 阅读更多
280 次浏览
首先,我们创建一个表:
mysql> create table DemoTable615 (EmployeeId varchar(100), EmployeeName varchar(100));
Query OK, 0 rows affected (0.62 sec)
使用insert命令在表中插入一些记录:
mysql> insert into DemoTable615 values('EMP-101', 'Adam');
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable615 values('EMP-1001', 'David');
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable615 values('EMP-1002', 'Chris');
Query OK, 1 row affected (0.08 sec)
mysql> insert into DemoTable615 values('EMP-1003', 'Robert');
Query OK, 1 row affected (0.21 sec)
使用select语句显示表中的所有记录:
mysql> select * from DemoTable615;
这将产生以下输出:
+------------+--------------+
| ... 阅读更多