找到 4379 篇文章 适用于 MySQL
81 次查看
为了更快地查询,您需要使用 MySQL IN()。让我们首先创建一个表 - mysql> create table DemoTable1538 -> ( -> ClientId int, -> ClientName varchar(20) -> ); Query OK, 0 rows affected (0.59 sec)插入一些记录到表中使用 insert 命令 - mysql> insert into DemoTable1538 values(101, 'Chris'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1538 values(102, 'Robert'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1538 values(103, 'Bob'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1538 values(104, 'Adam'); Query OK, 1 row affected (0.16 sec)显示 ... 阅读更多
35 次查看
为此可以使用 MySQL 中的 DATE_FORMAT()。让我们首先创建一个表 - mysql> create table DemoTable -> ( -> PurchaseDate date, -> Amount int -> ); Query OK, 0 rows affected (0.52 sec)插入一些记录到表中使用 insert 命令 - mysql> insert into DemoTable values('2019-10-12', 500); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('2018-10-12', 1000); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('2019-01-10', 600); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('2018-10-12', 600); Query OK, 1 row affected (0.15 sec) mysql> insert ... 阅读更多
265 次查看
为此,请使用 BETWEEN 关键字。让我们首先创建一个表 - mysql> create table DemoTable1537 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20) -> ); Query OK, 0 rows affected (0.72 sec)插入一些记录到表中使用 insert 命令 - mysql> insert into DemoTable1537(StudentName) values('Chris'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1537(StudentName) values('Bob'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1537(StudentName) values('Sam'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1537(StudentName) values('Mike'); Query OK, 1 row affected (0.16 sec) mysql> insert into ... 阅读更多
1K+ 次查看
为此,您可以使用带有多个 LIKE 的 WHERE 子句。让我们首先创建一个表 - mysql> create table DemoTable1536 -> ( -> Sentence text -> ); Query OK, 0 rows affected (0.51 sec)插入一些记录到表中使用 insert 命令 - mysql> insert into DemoTable1536 values('I like MySQL database.'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1536 values('Java is an Object Oriented Programming Language'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable1536 values('I only like data structure'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1536 values('MongoDB is ... 阅读更多
484 次查看
要按第一个字母排序,请使用 ORDER BY CASE 语句。让我们首先创建一个表 - mysql> create table DemoTable1535 -> ( -> Value varchar(100) -> ); Query OK, 0 rows affected (2.26 sec)插入一些记录到表中使用 insert 命令 - mysql> insert into DemoTable1535 values('MySQL is good relational database.'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1535 values('is MySQL easy to lean'); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable1535 values('You need to start basic SQL'); Query OK, 1 row affected (0.35 sec)显示表中的所有记录 ... 阅读更多
1K+ 次查看
让我们首先创建一个表。我们将其中一列设置为 TINYINT 类型 - mysql> create table DemoTable -> ( -> EmployeeId int, -> isMarried tinyint -> ); Query OK, 0 rows affected (6.84 sec)插入一些记录到表中使用 insert 命令 - mysql> insert into DemoTable values(101, true); Query OK, 1 row affected (1.94 sec) mysql> insert into DemoTable values(102, false); Query OK, 1 row affected (0.76 sec) mysql> insert into DemoTable values(103, true); Query OK, 1 row affected (1.14 sec) mysql> insert into DemoTable values(104, true); Query OK, 1 row affected (1.22 ... 阅读更多
738 次查看
要实现多个 LIKE 子句,语法如下 - select * from yourTableName where yourColumnName1 LIKE ('%yourValue1%' or yourColumnName2 LIKE '%yourValue2%') or (yourColumnName3 LIKE '%yourValue3');让我们首先创建一个表 - mysql> create table DemoTable1534 -> ( -> ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ClientName varchar(20), -> ClientAge int, -> ClientCountryName varchar(20) -> ); Query OK, 0 rows affected (0.78 sec)插入一些记录到表中使用 insert 命令 - mysql> insert into DemoTable1534(ClientName, ClientAge, ClientCountryName) values('Chris Brown', 29, 'AUS'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1534(ClientName, ClientAge, ClientCountryName) ... 阅读更多
646 次查看
让我们首先创建一个表 - mysql> create table DemoTable -> ( -> Value int -> ); Query OK, 0 rows affected (1.33 sec)插入一些记录到表中使用 insert 命令 - mysql> insert into DemoTable values(25); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(75); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.13 sec)使用 select 语句显示表中的所有记录 - mysql> select * from DemoTable;这将产生以下输出 -+-------+ | Value | +-------+ | 25 | | ... 阅读更多
537 次查看
为此,请在 MySQL 中使用 INET_ATON()。INET_ATON() 方法允许用户将 IP 地址记录转换为数字,然后我们可以使用 ORDER BY 对其进行排序。让我们先创建一个表 -mysql> create table DemoTable -> ( -> IpAddress varchar(50) -> ); Query OK, 0 rows affected (1.36 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('192.168.110.78'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('192.168.110.87'); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable values('192.168.110.75'); Query OK, 1 row affected (0.26 ... 阅读更多
776 次查看
为此,请使用子查询以及 MIN() 和 MAX()。要显示最大值和最小值,请使用 UNION ALL。让我们先创建一个表 -mysql> create table DemoTable -> ( -> EmployeeName varchar(20), -> EmployeeSalary int -> ); Query OK, 0 rows affected (0.70 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('Bob', 8800); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('Chris', 9800); Query OK, 1 row affected (0.63 sec) mysql> insert into DemoTable values('David', 7600); Query OK, 1 row affected (0.11 sec) mysql> ... 阅读更多