找到 4219 篇文章 关于 MySQLi
164 次浏览
为此,请结合使用 GROUP BY 子句和 MAX() 函数。让我们先创建一个表:mysql> create table DemoTable -> ( -> CountryName varchar(20), -> Population int -> ); Query OK, 0 rows affected (0.56 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('US', 560); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values('UK', 10090); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('UK', 8794); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('US', 1090); Query OK, 1 row affected (0.21 sec)显示 ... 阅读更多
112 次浏览
是的,因为这是一个全局权限。让我们先创建一个用户:mysql> CREATE USER 'Jace'@'localhost' IDENTIFIED BY 'Jace123'; Query OK, 0 rows affected (0.67 sec) 以下是使用 *.* 授予全局权限的查询:mysql> GRANT SELECT ON *.* TO 'Jace'@'localhost'; Query OK, 0 rows affected (0.58 sec) 现在您可以显示用户的全部权限:mysql> show grants for 'Jace'@'localhost'; 这将产生以下输出:+-------------------------------------------+ | Grants for Jace@localhost | +-------------------------------------------+ | GRANT SELECT ON *.* TO `Jace`@`localhost` | +-------------------------------------------+ 1 row in set (0.14 sec)
86 次浏览
为此,您可以使用 ORDER BY DATE() 函数。让我们先创建一个表。这里,我们有一个 DATE 类型的列和另一个 ENUM 类型的列:mysql> create table DemoTable -> ( -> JoiningDate date, -> Status ENUM('Good', 'Excellent', 'Bad') -> ); Query OK, 0 rows affected (0.58 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('2019-01-21', 'Excellent'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(Status) values('Bad'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(Status) values('Good'); Query OK, 1 row affected (0.13 sec)显示所有 ... 阅读更多
121 次浏览
要排序,请使用 ORDER BY SUBSTRING() 函数。让我们先创建一个表:mysql> create table DemoTable -> ( -> Value varchar(40) -> ); Query OK, 0 rows affected (0.59 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('2321/78/54-6') -> ; Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('2321/78/54-8'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('2321/78/54-5'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('2321/78/54-9'); Query OK, 1 row affected (0.21 sec)使用 select 语句显示表中的所有记录 ... 阅读更多
185 次浏览
要仅显示时间戳值中的日期,请在 MySQL 中使用 FROM_UNIXTIME() 方法。让我们先创建一个表:mysql> create table DemoTable -> ( -> timestampValue bigint -> ); Query OK, 0 rows affected (0.70 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values(1538332200); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(1577730600); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(1488652200); Query OK, 1 row affected (0.12 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable;这将产生 ... 阅读更多
265 次浏览
为此,在使用 MySQL UPDATE 命令时,请结合使用子查询和 WHERE 子句。让我们先创建一个表:mysql> create table DemoTable -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.82 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values(100, 'Chris'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values(250, 'David'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable values(150, 'Mike'); Query OK, 1 row affected (0.12 sec)使用 select 语句显示表中的所有记录 ... 阅读更多
135 次浏览
您可以结合使用 CHAR_LENGTH() 函数和 WHERE 子句。让我们先创建一个表:mysql> create table DemoTable -> ( -> FullName varchar(50) -> ); Query OK, 0 rows affected (1.75 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('Chris Brown'); Query OK, 1 row affected (0.40 sec) mysql> insert into DemoTable values('David Miller'); Query OK, 1 row affected (0.91 sec) mysql> insert into DemoTable values('Robert Miller'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values('John Smith'); Query OK, 1 row affected (0.89 sec)显示表中的所有记录 ... 阅读更多
2K+ 次浏览
要拆分列,您需要在 MySQL 中使用 SUBSTRING_INDEX() 函数。让我们先创建一个表:mysql> create table DemoTable -> ( -> Name varchar(40) -> ); Query OK, 0 rows affected (1.80 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('John_Smith'); Query OK, 1 row affected (0.36 sec) mysql> insert into DemoTable values('Carol_Taylor'); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable values('David_Miller'); Query OK, 1 row affected (0.54 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable;这将产生以下输出:+--------------+ ... 阅读更多
154 次浏览
让我们先创建一个表:mysql> create table DemoTable -> ( -> JoiningDate datetime -> ); Query OK, 0 rows affected (0.59 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('2015-01-21'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('2017-04-02'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('2018-12-31'); Query OK, 1 row affected (0.16 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable;这将产生以下输出:+---------------------+ | JoiningDate | +---------------------+ | 2015-01-21 00:00:00 ... 阅读更多
49 次浏览
是的,可以使用 # 符号。让我们先创建一个表:mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY , # 创建序列号 -> FirstName varchar(20), # 创建一个存储名称的列 -> Age int # 创建一个存储年龄的列 -> ); Query OK, 0 rows affected (1.43 sec) 上面,我们使用 # 符号设置了注释。使用 insert 命令在表中插入一些记录。我们还将使用相同的 # 符号在 insert 语句中设置注释 ... 阅读更多
数据结构
网络
关系数据库管理系统 (RDBMS)
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP