找到 4219 篇文章 关于 MySQLi
383 次查看
要为密码设置特殊字符,请使用以下语法:create user 'yourUserName'@'yourHostName' identified by 'yourSpecialCharacterPassword';让我们实现上述语法,以创建一个新用户并设置带有特殊字符的密码:mysql> create user 'Mike'@'localhost' identified by 'Mike_123456'; Query OK, 0 rows affected (0.35 sec)让我们检查MySQL用户和主机存储的表:mysql> select user, host from MySQL.user;这将产生以下输出。新用户创建成功:+------------------+-----------+ | user | host | +------------------+-----------+ | Bob | ... 阅读更多
402 次查看
是的,我们可以使用 MySQL 中的 DROP 删除主键。以下是语法:alter table yourTableName drop primary key;让我们首先创建一个表:mysql> create table DemoTable ( UserId int NOT NULL PRIMARY KEY ); Query OK, 0 rows affected (0.58 sec)以下是检查表描述的查询:mysql> desc DemoTable;这将产生以下输出,显示主键:+--------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+---------+------+-----+---------+-------+ | UserId | int(11) | NO | PRI ... 阅读更多
6K+ 次查看
要获取 max(id),请在 MySQL 中使用 MAX() 方法。以下是语法:select MAX(yourColumnName) AS anyAliasName from yourTableName;让我们首先创建一个表:mysql> create table DemoTable710 (Id int); Query OK, 0 rows affected (0.53 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable710 values(1001); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable710 values(2001); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable710 values(1998); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable710 values(1789); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable710 values(1678); Query OK, 1 ... 阅读更多
486 次查看
让我们首先创建一个表:mysql> create table DemoTable709 (Amount int); Query OK, 0 rows affected (0.62 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable709 values(100); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable709 values(560); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable709 values(7800); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable709 values(1020); Query OK, 1 row affected (0.15 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable709;这将产生以下输出:-+--------+ | Amount | +--------+ | 100 ... 阅读更多
2K+ 次查看
让我们首先创建一个表:mysql> create table DemoTable708 ( CustomerName varchar(100), ShippingDate date ); Query OK, 0 rows affected (0.51 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable708 values('John', '2019-01-21'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable708 values('Chris', '2019-03-24'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable708 values('Robert', '2019-04-26'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable708 values('David', '2019-07-22'); Query OK, 1 row affected (0.17 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable708;这将产生... 阅读更多
162 次查看
让我们首先创建一个表:mysql> create table DemoTable707 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(100), StudentMarks int ); Query OK, 0 rows affected (0.59 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable707(StudentFirstName, StudentMarks) values('John', 45); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable707(StudentFirstName, StudentMarks) values(NULL, 65); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable707(StudentFirstName, StudentMarks) values('Chris', 78); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable707(StudentFirstName, StudentMarks) values(NULL, 89); Query OK, 1 row affected (0.19 sec) mysql> insert into ... 阅读更多
181 次查看
为此,以下是我们使用 DATE(NOW()) 的语法:select *from yourTableName where DATE(yourColumnName)=DATE(NOW());让我们首先创建一个表:mysql> create table DemoTable706 ( UserId varchar(100), UserName varchar(100), UserSignupDate datetime ); Query OK, 0 rows affected (0.57 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable706 values('[email protected]', 'John', '2019-01-31 12:45:22'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable706 values('[email protected]', 'Chris', '2019-07-22 10:05:02'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable706 values('[email protected]', 'Robert', '2019-06-22 11:25:22'); Query OK, 1 row affected (0.22 sec) mysql> insert into ... 阅读更多
218 次查看
假设当前日期为:2019-07-22让我们首先创建一个表:mysql> create table DemoTable705 (ShippingDate datetime); Query OK, 0 rows affected (0.67 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable705 values('2019-01-21 23:59:00'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable705 values('2019-07-22 00:00:30'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable705 values('2019-07-21 12:01:30'); Query OK, 1 row affected (0.44 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable705;这将产生以下输出:-+---------------------+ | ShippingDate | ... 阅读更多
309 次查看
让我们首先创建一个表:mysql> create table DemoTable704 (SubjectName text); Query OK, 0 rows affected (0.58 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable704 values('Introduction to MySQL'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable704 values('Introduction to MongoDB'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable704 values('Introduction to MySQL'); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable704 values('Introduction to Java'); Query OK, 1 row affected (0.39 sec) mysql> insert into DemoTable704 values('Introduction to MongoDB'); Query OK, 1 row affected (0.14 sec) mysql> insert into ... 阅读更多
186 次查看
为此,您可以使用 CASE 语句。让我们先创建一个表 - mysql> create table DemoTable703 (Price int); Query OK, 0 rows affected (0.46 sec) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable703 values(102); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable703 values(null); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable703 values(0); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable703 values(500); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable703 values(100); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable703 values(null); Query ... 阅读更多