找到 4219 篇文章 关于 MySQLi
181 次查看
让我们先创建一个表 -mysql> create table DemoTable676( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Number int ); Query OK, 0 rows affected (0.50 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable676(Number) values(1000); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable676(Number) values(1839); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable676(Number) values(29894); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable676(Number) values(1264); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable676(Number) values(190); Query OK, 1 row affected (0.17 sec) mysql> insert into ... 阅读更多
410 次查看
要搜索逗号分隔值的表,请使用 LIKE 运算符。让我们先创建一个表 -mysql> create table DemoTable675(Value text); Query OK, 0 rows affected (0.55 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable675 values('10, 56, 49484, 93993, 211, 4594'); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable675 values('4, 7, 1, 10, 90, 23'); Query OK, 1 row affected (0.41 sec) mysql> insert into DemoTable675 values('90, 854, 56, 89, 10'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable675 values('11, 22, 344, 67, 89'); Query OK, 1 row ... 阅读更多
68 次查看
是的,我们可以在 insert 语句中命名列。让我们先创建一个表 -mysql> create table DemoTable674( StudentId int, StudentFirstName varchar(100), StudentLastName varchar(100) ); Query OK, 0 rows affected (0.82 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable674 set StudentId=10, StudentFirstName='John', StudentLastName='Smith'; Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable674 set StudentId=11, StudentFirstName='Carol', StudentLastName='Taylor'; Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable674 set StudentId=12, StudentFirstName='David', StudentLastName='Miller'; Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable674 set StudentId=13, StudentFirstName='Chris', StudentLastName='Brown'; Query OK, 1 ... 阅读更多
1K+ 次查看
为此,请使用 GROUP BY HAVING 子句。让我们先创建一个表 -mysql> create table DemoTable673( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value int ); Query OK, 0 rows affected (0.59 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable673(Value) values(10); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable673(Value) values(20); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable673(Value) values(10); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable673(Value) values(30); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable673(Value) values(20); Query OK, 1 ... 阅读更多
254 次查看
为此,请使用 order by nullif()。让我们先创建一个表 -mysql> create table DemoTable672( CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY, CustomerName varchar(100), CustomerAmount int ); Query OK, 0 rows affected (0.81 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable672(CustomerName, CustomerAmount) values('Chris', 560); Query OK, 1 row affected (0.51 sec) mysql> insert into DemoTable672(CustomerName, CustomerAmount) values('Robert', null); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable672(CustomerName, CustomerAmount) values('', 450); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable672(CustomerName, CustomerAmount) values('David', 456); Query OK, 1 row affected ... 阅读更多
84 次查看
对于以特定字母开头的特定类型的列,请使用 LIKE。要连接列名,请使用 GROUP_CONCAT(),如下面的语法所示 -SELECT group_concat(COLUMN_NAME separator ' , ') FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = "yourTableName" AND table_schema = "yourDatabaseName" AND column_name LIKE "yourSpecificLetter%";让我们先创建一个表 -mysql> create table DemoTable671( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(100), ClientAge int, ClientAddress varchar(200), ClientCountryName varchar(100) ); Query OK, 0 rows affected (0.62 sec)以下是选择以特定字母开头的特定类型的列并获取所有列的查询 ... 阅读更多
97 次查看
要排序域名,请使用 ORDER BY SUBSTRING_INDEX()。让我们先创建一个表 -mysql> create table DemoTable670(DomainName text); Query OK, 0 rows affected (0.77 sec)使用 insert 命令在表中插入一些记录。在这里,我们正在插入域名 -mysql> insert into DemoTable670 values('www.facebook.com'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable670 values('www.google.com'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable670 values('www.amazon.com'); Query OK, 1 row affected (0.19 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable670;这将产生以下输出 -+------------------+ | DomainName ... 阅读更多
132 次查看
为此,请使用 ORDER BY ISNULL()。让我们先创建一个表 -mysql> create table DemoTable669 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentScore int ); Query OK, 0 rows affected (0.55 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable669(StudentScore) values(45) ; Query OK, 1 row affected (0.80 sec) mysql> insert into DemoTable669(StudentScore) values(null); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable669(StudentScore) values(89); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable669(StudentScore) values(null); Query OK, 1 row affected (0.15 sec)使用 select ... 阅读更多
2K+ 次查看
让我们先创建一个表 -mysql> create table DemoTable668(JoiningDate varchar(200)); Query OK, 0 rows affected (0.97 sec)使用 insert 命令在表中插入一些记录。我们已按 yyyy-mm-ddThh:mm:ss.sssZ 格式插入日期 -mysql> insert into DemoTable668 values('2001-01-10T06:20:00.000Z'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable668 values('2019-07-20T04:00:00.000Z'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable668 values('2016-02-12T05:10:50.000Z'); Query OK, 1 row affected (0.17 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable668;这将产生以下输出 -+--------------------------+ | JoiningDate | +--------------------------+ | ... 阅读更多
1K+ 次查看
假设当前日期是 2019-07-25。我们现在来看一个例子,创建一个包含 ShippingDate 字段的表。让我们首先创建一个表 -mysql> create table DemoTable667(ShippingDate datetime); Query OK, 0 rows affected (0.46 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable667 values('2019-01-31'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable667 values('2019-07-19'); Query OK, 1 row affected (0.69 sec) mysql> insert into DemoTable667 values('2019-07-23'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable667 values('2019-08-24'); Query OK, 1 row affected (0.15 sec)显示所有记录来自 ... 阅读更多