找到 4219 篇文章 关于 MySQLi
1K+ 次浏览
让我们首先创建一个表 - mysql> create table DemoTable1510 -> ( -> Value varchar(50) -> ); Query OK, 0 rows affected (6.75 sec) 使用 insert 命令插入一些记录 - mysql> insert into DemoTable1510 values('20, 35'); Query OK, 1 row affected (0.57 sec) mysql> insert into DemoTable1510 values('45, 67, 89'); Query OK, 1 row affected (0.99 sec) mysql> insert into DemoTable1510 values('90, 97, 101, 190'); Query OK, 1 row affected (1.15 sec) 使用 select 命令显示表中的所有记录 - mysql> select * from DemoTable1510; 这将产生以下输出 - +---------------+ | Value | ... 阅读更多
1K+ 次浏览
您可以使用 MySQL 的 LEFT() 函数。让我们首先创建一个表 - mysql> create table DemoTable1428 -> ( -> EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> EmployeeName varchar(20) -> ); Query OK, 0 rows affected (1.05 sec) 使用 insert 命令插入一些记录 - mysql> insert into DemoTable1428(EmployeeName) values('Chris Brown'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1428(EmployeeName) values('Bob Brown'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1428(EmployeeName) values('John Smith'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable1428(EmployeeName) values('David Miller'); Query OK, 1 row affected (0.18 sec) ... 阅读更多
439 次浏览
为此,您可以使用子查询。让我们首先创建一个表 - mysql> create table DemoTable1427 -> ( -> StudentId int, -> StudentMarks int -> ); Query OK, 0 rows affected (1.28 sec) 使用 insert 命令插入一些记录 - mysql> insert into DemoTable1427 values(201, 89); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1427 values(201, 99); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1427 values(210, 98); Query OK, 1 row affected (0.16 sec) 使用 select 命令显示表中的所有记录 - mysql> select * from DemoTable1427 ; 这将产生以下输出 ... 阅读更多
73 次浏览
为此,您可以使用带有 LIMIT 的 ORDER BY RAND()。让我们首先创建一个表 - mysql> create table DemoTable1426 -> ( -> FirstName varchar(20) -> ); Query OK, 0 rows affected (0.59 sec) 使用 insert 命令插入一些记录 - mysql> insert into DemoTable1426 values('John'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1426 values('Adam'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1426 values('Robert'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1426 values('David'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1426 values('Sam'); Query OK, 1 row ... 阅读更多
152 次浏览
是的,您可以将聚合函数 COUNT(*) 与 GROUP BY 子句一起使用。让我们首先创建一个表 - mysql> create table DemoTable1425 -> ( -> JoiningYear int -> ); Query OK, 0 rows affected (0.76 sec) 使用 insert 命令插入一些记录 - mysql> insert into DemoTable1425 values(2000); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1425 values(2010); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable1425 values(2015); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1425 values(2000); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1425 values(2010); Query OK, ... 阅读更多
248 次浏览
为此,请使用 CONCAT() 和 SUBSTRING_INDEX()。让我们首先创建一个表 - mysql> create table DemoTable1424 -> ( -> Value varchar(60) -> ); Query OK, 0 rows affected (0.56 sec) 使用 insert 命令插入一些记录 - mysql> insert into DemoTable1424 values('567.78483733'); Query OK, 1 row affected (0.78 sec) mysql> insert into DemoTable1424 values('1023.45252443'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1424 values('7893322.5635543434'); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable1424 values('90944.665665'); Query OK, 1 row affected (0.14 sec) 使用 select 命令显示表中的所有记录 - mysql> select * from DemoTable1424; 这 ... 阅读更多
2K+ 次浏览
使用 FIND_IN_SET() 代替 MySQL IN()。让我们首先创建一个表 - mysql> create table DemoTable1423 -> ( -> CountryName varchar(100) -> ); Query OK, 0 rows affected (0.51 sec) 使用 insert 命令插入一些记录 - mysql> insert into DemoTable1423 values('AUS, UK'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable1423 values('US'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1423 values('AUS, UK, US'); Query OK, 1 row affected (0.13 sec) 使用 select 命令显示表中的所有记录 - mysql> select * from DemoTable1423; 这将产生以下输出 - +-------------+ | CountryName | +-------------+ ... 阅读更多
634 次浏览
要选择两个日期范围内的所有数据,请使用 MySQL BETWEEN - select * from yourTableName where yourColumnName between yourDateValue1 and yourDateValue2; 让我们首先创建一个表 - mysql> create table DemoTable1422 -> ( -> EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> EmployeeName varchar(20), -> EmployeeJoiningDate date -> ); Query OK, 0 rows affected (0.69 sec) 使用 insert 命令插入一些记录 - mysql> insert into DemoTable1422(EmployeeName, EmployeeJoiningDate) values('John', '2017-09-28'); Query OK, 1 row affected (0.39 sec) mysql> insert into DemoTable1422(EmployeeName, EmployeeJoiningDate) values('Chris', '2019-09-29'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1422(EmployeeName, EmployeeJoiningDate) ... 阅读更多