找到 4219 篇文章 关于 MySQLi
985 次浏览
为此,您可以创建一个存储过程。让我们首先创建一个表。mysql> create table DemoTable -> ( -> Value int -> ); Query OK, 0 rows affected (0.55 sec)以下是如何创建存储过程以从 10 到 20 的范围内自动插入值到表中的查询:mysql> DELIMITER // mysql> CREATE PROCEDURE AutoInsertValuesToTable() -> BEGIN -> DECLARE startingRange INT DEFAULT 10; -> WHILE startingRange INSERT DemoTable(Value) VALUES (startingRange ); -> SET startingRange = startingRange + 1; -> ... 阅读更多
546 次浏览
让我们首先创建一个表:mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Number int -> ); Query OK, 0 rows affected (0.50 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable(Number) values(10); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(Number) values(20); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(Number) values(30); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(Number) values(40); Query OK, 1 row affected (0.14 sec) 显示所有记录 ... 阅读更多
549 次浏览
在 MySQL 中使用不等于(!=)来从表中排除特定行。让我们首先创建一个表:mysql> create table DemoTable -> ( -> Id int, -> FirstName varchar(100) -> ); Query OK, 0 rows affected (0.58 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values(1, 'John'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(2, 'Chris'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(3, 'Robert'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable ... 阅读更多
652 次浏览
为此,您可以使用 GROUP BY HAVING 子句。让我们首先创建一个表:mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Subject varchar(100) -> ); Query OK, 0 rows affected (0.53 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable(Subject) values('MySQL'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(Subject) values('MongoDB'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable(Subject) values('MySQL'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(Subject) values('Java'); Query OK, 1 ... 阅读更多
1K+ 次浏览
为此,您可以使用 MySQL 中的 concat() 函数。让我们首先创建一个表:mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20), -> Subject varchar(100) -> ); Query OK, 0 rows affected (17.73 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable(Name, Subject) values('John', 'MySQL'); Query OK, 1 row affected (1.19 sec) mysql> insert into DemoTable(Name, Subject) values('Chris', 'SQL Server'); Query OK, 1 row affected (0.88 sec) mysql> insert into DemoTable(Name, Subject) values('Robert', 'MongoDB'); Query OK, 1 row affected ... 阅读更多
268 次浏览
让我们首先创建一个表:mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.69 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable(Name) values('Carol'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(Name) values('Chris'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(Name) values('David'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(Name) values('Bob'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(Name) ... 阅读更多
124 次浏览
如果给定一个包含文件路径的字符串,PHP basename() 函数将返回文件的基名称。要在 MySQL 中获取其等价物,可以使用 SUBSTRING_INDEX()。让我们首先创建一个表:mysql> create table DemoTable -> ( -> Location varchar(200) -> ); Query OK, 0 rows affected (1.02 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('C:\Web\Sum.java'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('E:\WebDevelopment\Image1.png'); Query OK, 1 row affected (0.42 sec)使用 select 语句显示表中的所有记录 ... 阅读更多
129 次浏览
让我们首先创建一个表:mysql> create table DemoTable -> ( -> Name varchar(100) -> ); Query OK, 0 rows affected (0.85 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(NULL); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(NULL); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('David'); Query OK, 1 row affected (0.17 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable;输出+-------+ | Name ... 阅读更多
390 次浏览
是的,我们可以使用 CASE 语句做到这一点。让我们首先创建一个表:mysql> create table DemoTable -> ( -> isMarried boolean -> ); Query OK, 0 rows affected (0.76 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values(true); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values(false); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(false); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(true); Query OK, 1 row affected (0.19 sec)显示表中的所有记录 ... 阅读更多
2K+ 次浏览
要将时间转换为秒,请使用 TIME_TO_SEC() 方法。让我们首先创建一个表:mysql> create table DemoTable -> ( -> ArrivalTime time -> ); Query OK, 0 rows affected (0.63 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('04:10:00'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('05:20:50'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('06:40:10'); Query OK, 1 row affected (0.18 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable;输出+-------------+ | ArrivalTime | +-------------+ | 04:10:00 ... 阅读更多