找到 4219 篇文章 关于 MySQLi
151 次浏览
让我们首先创建一个表 - mysql> create table DemoTable821(AdmissionDate datetime); Query OK, 0 rows affected (1.24 sec)插入一些记录到表中使用 insert 命令 - mysql> insert into DemoTable821 values('2019-01-21'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable821 values('2018-11-02'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable821 values('2016-12-31'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable821 values('2015-03-19'); Query OK, 1 row affected (0.17 sec)显示表中所有记录使用 select 语句 - mysql> select *from DemoTable821;这将产生以下输出 -+---------------------+ | AdmissionDate ... 阅读更多
222 次浏览
如果你将运算符与 NULL 值进行比较,那么你将始终得到 NULL 值,并且没有结果。让我们看一些比较示例 - mysql> select 10 NULL; +------------+ | 10 NULL | +------------+ | NULL | +------------+ 1 row in set (0.00 sec) mysql> select NULL NULL; +--------------+ | NULL NULL | +--------------+ | NULL | +--------------+ 1 row in set (0.00 sec) mysql> select 'Chris' NULL; +-----------------+ | 'Chris' NULL | +-----------------+ | NULL | +-----------------+ 1 row in ... 阅读更多
269 次浏览
要仅获取最后五条记录,以下是语法 - select *from yourTableName order by yourColumnName DESC LIMIT 5;让我们首先创建一个表 - mysql> create table DemoTable820( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, CustomerName varchar(100) ); Query OK, 0 rows affected (0.53 sec)插入一些记录到表中使用 insert 命令 - mysql> insert into DemoTable820(CustomerName) values('Chris'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable820(CustomerName) values('Robert'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable820(CustomerName) values('David'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable820(CustomerName) values('Bob'); Query OK, 1 ... 阅读更多
144 次浏览
要显示授予,语法如下 - show grants for yourUserName;让我们实现上述语法以在尝试创建数据库之前检查用户权限。案例 1 - 这是当前用户,即 root。以下是语法 - mysql> show grants for current_user;这将产生以下输出 -+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Grants for root@% ... 阅读更多
1K+ 次浏览
让我们首先创建一个表 - mysql> create table DemoTable819( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(100) ); Query OK, 0 rows affected (0.88 sec)插入一些记录到表中使用 insert 命令 - mysql> insert into DemoTable819(StudentName) values('Chris'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable819(StudentName) values('Robert'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable819(StudentName) values('Adam'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable819(StudentName) values('Mike'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable819(StudentName) values('Sam'); Query OK, 1 row affected (0.16 sec)显示所有记录从 ... 阅读更多
1K+ 次浏览
让我们首先创建一个表 - mysql> create table DemoTable845(AdmissionDate date); Query OK, 0 rows affected (1.10 sec)插入一些记录到表中使用 insert 命令 - mysql> insert into DemoTable845 values('2018-01-21'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable845 values('2016-12-12'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable845 values('2019-08-05'); Query OK, 1 row affected (0.44 sec) mysql> insert into DemoTable845 values('2019-10-15'); Query OK, 1 row affected (0.19 sec)显示表中所有记录使用 select 语句 - mysql> select *from DemoTable845;这将产生以下输出 -+---------------+ | AdmissionDate | +---------------+ | 2018-01-21 | ... 阅读更多
1K+ 次浏览
使用 SHA2() 将 MD5 密码转换为 SHA256。它计算 SHA-2 系列的哈希函数,即 SHA-224、SHA-256、SHA-384 和 SHA-512)。让我们首先创建一个表 - mysql> create table DemoTable818(UserPassword text); Query OK, 0 rows affected (0.51 sec)插入一些记录到表中使用 insert 命令 - mysql> insert into DemoTable818 values(MD5('John_123')); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable818 values(MD5('999Carol@22')); Query OK, 1 row affected (0.14 sec)显示表中所有记录使用 select 语句 - mysql> select *from DemoTable818;这将产生以下输出 -+----------------------------------+ | UserPassword ... 阅读更多
139 次浏览
为此,您可以使用子查询。让我们首先创建一个表 - mysql> create table DemoTable844( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Amount int ); Query OK, 0 rows affected (0.95 sec)插入一些记录到表中使用 insert 命令 - mysql> insert into DemoTable844(Amount) values(80); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable844(Amount) values(100); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable844(Amount) values(60); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable844(Amount) values(40); Query OK, 1 row affected (0.36 sec) mysql> insert into DemoTable844(Amount) values(150); Query OK, 1 row ... 阅读更多
130 次浏览
使用 IFNULL 检查 NULL 值并使用 SET 命令设置值。让我们首先创建一个表 - mysql> create table DemoTable817(Value int); Query OK, 0 rows affected (0.53 sec)插入一些记录到表中使用 insert 命令 - mysql> insert into DemoTable817 values(10); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable817 values(null); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable817 values(20); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable817 values(null); Query OK, 1 row affected (0.11 sec)显示表中所有记录使用 select 语句 - mysql> select *from ... 阅读更多
184 次浏览
使用INFORMATION_SCHEMA.SCHEMA_PRIVILEGES显示用户的所有授权 - 选择*from INFORMATION_SCHEMA.SCHEMA_PRIVILEGES;让我们实现上述语法以显示用户的所有授权 - mysql> select *from INFORMATION_SCHEMA.SCHEMA_PRIVILEGES;这将产生以下输出 -+-----------------------------+---------------+--------------------+-------------------------+--------------+ | GRANTEE | TABLE_CATALOG | TABLE_SCHEMA | PRIVILEGE_TYPE | IS_GRANTABLE | +-----------------------------+---------------+--------------------+-------------------------+--------------+ | 'mysql.sys'@'localhost' | def | sys | TRIGGER | NO ... 阅读更多