找到 4219 篇文章 适用于 MySQLi
507 次浏览
让我们首先创建一个表 - mysql> create table DemoTable ( Value int ); Query OK, 0 rows affected (0.57 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values(80); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(90); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(90); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(80); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(90); Query OK, 1 row affected ... 阅读更多
172 次浏览
由于我们需要最后 3 位数字的和,我们需要使用聚合函数 SUM() 以及 RIGHT()。让我们首先创建一个表 - mysql> create table DemoTable ( Code int ); Query OK, 0 rows affected (0.77 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values(5464322); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(90884); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(23455644); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(4353633); Query OK, 1 row affected (0.11 sec)显示表中的所有记录 ... 阅读更多
445 次浏览
这里,假设您有一个字符串,格式为“StringSeparatorNumber”,例如 John/56989。现在,如果您想删除分隔符 / 后面的数字,请使用 SUBSTRING_INDEX()。让我们首先创建一个表 - mysql> create table DemoTable ( StudentName varchar(100) ); Query OK, 0 rows affected (1.05 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('John/56989'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('Carol'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('David/74674'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('Bob/45565'); Query ... 阅读更多
371 次浏览
为此,请使用 MySQL REPLACE()。让我们首先创建一个表 - mysql> create table DemoTable ( FolderLocation text ); Query OK, 0 rows affected (0.80 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('C/ProgramFiles/AllMySQLProgram'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('C/ProgramFiles/JavaChatApplication'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('C/ProgramFiles/Main/Image.png'); Query OK, 1 row affected (0.18 sec)使用 select 语句显示表中的所有记录 - mysql> select *from DemoTable;这将产生以下输出 -+------------------------------------+ | FolderLocation ... 阅读更多
51 次浏览
是的,我们可以在一个条件下同时检查空字符串和 0。让我们首先创建一个表 - mysql> create table DemoTable ( ClientId varchar(40) ); Query OK, 0 rows affected (1.01 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('CLI-01'); Query OK, 1 row affected (0.36 sec) mysql> insert into DemoTable values('0'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('CLI-02'); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable values('CLI-00'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(''); Query OK, 1 ... 阅读更多
555 次浏览
要将行折叠成逗号分隔列表,请使用 GROUP_CONCAT()。让我们首先创建一个表 - mysql> create table DemoTable ( Id int, Name varchar(40) ); Query OK, 0 rows affected (0.52 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values(100, 'Chris Brown'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(101, 'Adam Smith'); Query OK, 1 row affected (0.84 sec) mysql> insert into DemoTable values(101, 'John Doe'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(100, 'David Miller'); Query OK, 1 row affected (0.17 sec) mysql> insert ... 阅读更多
832 次浏览
在 MySQL 中,您可以借助 SHOW CREATE 命令实现 sp_help。情况 1 -对于表,语法如下 -SHOW CREATE TABLE yourTableName;情况 2 -对于存储过程,语法如下 -SHOW CREATE PROCEDURE yourProcedureName;让我们首先创建一个表 - mysql> create table DemoTable ( EmployeeId int NOT NULL AUTO_INCREMENT, EmployeeFirstName varchar(40) NOT NULL, EmployeeLastName varchar(40) NOT NULL, EmployeeAge int, EmployeeCountryName varchar(40), EmployeeCityName varchar(40), PRIMARY KEY(EmployeeId), UNIQUE KEY(EmployeeFirstName, EmployeeCityName) ); Query OK, 0 rows affected (0.97 sec)让我们对我们的表实现上述语法 - mysql> SHOW CREATE TABLE ... 阅读更多
266 次浏览
为此,您可以使用 SUBSTRING_INDEX()。让我们首先创建一个表 - mysql> create table DemoTable ( Words TEXT ); Query OK, 0 rows affected (1.62 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('Learn With Ease'); Query OK, 1 row affected (0.32 sec) mysql> insert into DemoTable values('Intro To MySQL'); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable values('Deep Dive Using Java'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('C++ In Depth'); Query OK, 1 row affected (0.16 sec)显示表中的所有记录使用 select ... 阅读更多
83 次浏览
让我们首先创建一个表 - mysql> create table DemoTable ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(40), ClientAge int, ClientCountryName varchar(40) ); Query OK, 0 rows affected (0.57 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable(ClientName, ClientAge, ClientCountryName) values('Chris', 25, 'US'); Query OK, 1 row affected (0.33 sec) mysql> insert into DemoTable(ClientName, ClientAge, ClientCountryName) values('Bob', 55, 'UK'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(ClientName, ClientAge, ClientCountryName) values('David', 45, 'AUS'); Query OK, 1 row affected (0.14 sec)显示表中的所有记录使用 select 语句 ... 阅读更多
2K+ 次浏览
首先让我们创建一个表 -mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(20) ); Query OK, 0 rows affected (0.71 sec)使用insert命令在表中插入一些记录 -mysql> insert into DemoTable(StudentName) values('Chris'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(StudentName) values('David'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable(StudentName) values('Sam'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(StudentName) values('Mike'); Query OK, 1 row affected (0.12 sec)使用select语句显示表中的所有记录 -mysql> select * from DemoTable;这将... 阅读更多