找到 4219 篇文章 关于 MySQLi
131 次浏览
是的,MySQL “WHERE…OR” 的替代方案是使用 REGEXP。让我们先创建一个表:mysql> create table DemoTable684(EmployeeInformation text); Query OK, 0 rows affected (0.68 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable684 values('John 21 Google'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable684 values('Carol 23 Amazon'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable684 values('Carol 26 Flipkart'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable684 values('David 29 Microsoft'); Query OK, 1 row affected (0.18 sec) 使用 select 语句显示表中的所有记录:mysql> ... 阅读更多
1K+ 次浏览
要选择前 10 条记录,我们可以先按升序或降序对记录进行排序。然后,使用 LIMIT 10 只获取 10 条记录:select *from (select *from yourTableName ORDER BY yourColumnName ASC LIMIT 10)anyAliasName ORDER BY yourColumnName DESC; 让我们先创建一个表:mysql> create table DemoTable683(Page int); Query OK, 0 rows affected (0.83 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable683 values(100); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable683 values(101); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable683 values(102); Query OK, 1 row affected ... 阅读更多
71 次浏览
让我们先创建一个表:mysql> create table DemoTable793( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(100) ); Query OK, 0 rows affected (0.81 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable793(StudentName) values('Adam'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable793(StudentName) values('Bob'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable793(StudentName) values(null); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable793(StudentName) values('Chris'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable793(StudentName) values('Robert'); Query OK, 1 row affected (1.03 sec) 显示所有记录... 阅读更多
1K+ 次浏览
要连接字符串和数字,请使用 CONCAT() 方法。让我们先创建一个表:mysql> create table DemoTable682( Name varchar(100), Age int ); Query OK, 0 rows affected (0.49 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable682 values('John', 23); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable682 values('Chris', 21); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable682 values('David', 25); Query OK, 1 row affected (0.17 sec) 使用 select 语句显示表中的所有记录:使用 select 语句显示表中的所有记录 -mysql> select *from ... 阅读更多
2K+ 次浏览
要选择两个日期之间的日期记录,您需要使用 BETWEEN 关键字。让我们先创建一个表:mysql> create table DemoTable681(AdmissionDate datetime); Query OK, 0 rows affected (0.75 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable681 values('2019-01-21'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable681 values('2019-11-01'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable681 values('2019-12-03'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable681 values('2019-07-03'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable681 values('2019-02-04'); Query OK, 1 row affected (0.34 ... 阅读更多
115 次浏览
要在 MySQL 中只返回一次列值,让我们首先看一个例子并创建一个表:mysql> create table DemoTable680(Status varchar(100)); Query OK, 0 rows affected (0.75 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable680 values('Busy'); Query OK, 1 row affected (0.36 sec) mysql> insert into DemoTable680 values('At Work'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable680 values('Busy'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable680 values('Blocked'); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable680 values('Offline'); Query OK, 1 row affected (0.67 sec) ... 阅读更多
86 次浏览
让我们先创建一个表:mysql> create table DemoTable679(FirstName varchar(100)); Query OK, 0 rows affected (0.44 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable679 values('John'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable679 values('Chris'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable679 values('David'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable679 values('Bob'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable679 values('Mike'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable679 values('Sam'); Query OK, 1 row affected (0.15 sec) mysql> insert ... 阅读更多
493 次浏览
为此,请在 MySQL 中使用 ORDER BY STR_TO_DATE,如下所示:select *from yourTableName ORDER BY STR_TO_DATE(yourColumnName, '%M %Y') DESC; 让我们先创建一个表:mysql> create table DemoTable678(DueDate varchar(200)); Query OK, 0 rows affected (0.62 sec) 使用 insert 命令在表中插入一些记录。我们在这里插入了日期:mysql> insert into DemoTable678 values('March 2019'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable678 values('November 2018'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable678 values('January 2019'); Query OK, 1 row affected (0.18 sec) 使用 select 语句显示表中的所有记录:mysql> ... 阅读更多
365 次浏览
要设置自定义字段值,请使用 FIND_IN_SET()。让我们先创建一个表:mysql> create table DemoTable677( UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, UserStatus text ); Query OK, 0 rows affected (1.07 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable677(UserStatus) values('BUSY'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable677(UserStatus) values('AT WORK'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable677(UserStatus) values('OFFLINE'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable677(UserStatus) values('BLOCKED'); Query OK, 1 row affected (0.17 sec) 使用 select ... 阅读更多
467 次浏览
CONCAT() 方法将用于将“MR”连接到每个字符串,而 GROUP_CONCAT() 用于将一些列值连接到一行。让我们首先看一个例子并创建一个表:mysql> create table DemoTable799( UserId int, UserName varchar(100), UserAge int ); Query OK, 0 rows affected (0.56 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable799 values(101, 'John', 21); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable799 values(102, 'Chris', 26); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable799 values(101, 'Robert', 23); Query OK, ... 阅读更多