找到 4379 篇文章 适用于 MySQL
613 次查看
斜杠在 MySQL 查询中表示除法 (/)。它可以用于对两个数字进行除法运算。这里,我们将看到一个示例,从两个列中除法数字并在新列中显示结果。让我们首先创建一个表 -mysql> create table DemoTable719 ( FirstNumber int, SecondNumber int ); Query OK, 0 rows affected (0.57 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable719 values(20, 10); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable719 values(500, 50); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable719 values(400, 20); ... 阅读更多
2K+ 次查看
为此,您可以使用 NOT IN() 函数。让我们首先创建一个表 -mysql> create table DemoTable718 ( Id int, FirstName varchar(100), Age int ); Query OK, 0 rows affected (0.59 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable718 values(101, 'Chris', 26); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable718 values(102, 'Robert', 24); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable718 values(103, 'David', 27); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable718 values(104, 'Mike', 28); Query OK, 1 row affected (0.19 sec) mysql> ... 阅读更多
770 次查看
让我们首先创建一个表 -mysql> create table DemoTable717 ( UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, UserPassword int ); Query OK, 0 rows affected (0.81 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable717(UserPassword) values(1454343); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable717(UserPassword) values(674654); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable717(UserPassword) values(989883); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable717(UserPassword) values(909983); Query OK, 1 row affected (0.15 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable717;这将产生 ... 阅读更多
394 次查看
让我们首先创建一个表 -mysql> create table DemoTable716 ( Id varchar(100), Value1 int, Value2 int, Value3 int ); Query OK, 0 rows affected (0.65 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable716 values('100', 45, 86, 79); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable716 values('101', 67, 67, 99); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable716 values('102', 77, 57, 98); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable716 values('103', 45, 67, 92); Query OK, 1 row affected (0.16 sec)显示所有 ... 阅读更多
86 次查看
为此,您可以使用 ORDER BY IF(CAST())。让我们首先创建一个表 -mysql> create table DemoTable(EmployeeCode varchar(100)); Query OK, 0 rows affected (1.17 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('190'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('100'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values('120'); Query OK, 1 row affected (0.21 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable;这将产生以下输出 -+--------------+ ... 阅读更多
665 次查看
要在 MySQL 中按列的长度排序,请使用 ORDER BY LENGTH。让我们首先创建一个表 -mysql> create table DemoTable715 (UserMessage varchar(100)); Query OK, 0 rows affected (0.56 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable715 values('Aw'); Query OK, 1 row affected (0.49 sec) mysql> insert into DemoTable715 values('Awe'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable715 values('A'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable715 values('Awes'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable715 values('Awesom'); Query OK, 1 row affected (0.16 sec) mysql> insert ... 阅读更多
941 次查看
让我们首先创建一个表 -mysql> create table DemoTable1 (FirstName varchar(100)); Query OK, 0 rows affected (0.54 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1 values('Bob'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1 values('James'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1 values('John'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1 values('David'); Query OK, 1 row affected (0.18 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable1;这将产生以下输出 -+-----------+ | FirstName | +-----------+ | Bob ... 阅读更多
2K+ 次查看
让我们首先创建一个表 -mysql> create table DemoTable ( Id int, Name varchar(100) ); Query OK, 0 rows affected (1.40 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values(100, 'John'); Query OK, 1 row affected (0.44 sec) mysql> insert into DemoTable values(101, 'Chris'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(102, 'Chris'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(103, 'Chris'); Query OK, 1 row affected (1.05 sec) mysql> insert into DemoTable values(104, 'David'); Query OK, 1 ... 阅读更多
1K+ 次查看
要比较日期字符串,请使用 MySQL 中的 STR_TO_DATE()。让我们首先创建一个表 -mysql> create table DemoTable712 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ArrivalDate varchar(100) ); Query OK, 0 rows affected (0.65 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable712(ArrivalDate) values('10.01.2019'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable712(ArrivalDate) values('11.12.2018'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable712(ArrivalDate) values('01.11.2017'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable712(ArrivalDate) values('20.06.2016'); Query OK, 1 row affected (0.23 sec)显示表中的所有记录,使用 select ... 阅读更多
93 次查看
在 MySQL 中,IN 使用索引,而 OR 不使用索引。让我们先创建一个表:
mysql> create table DemoTable711 ( Id int, Name varchar(100) );
Query OK, 0 rows affected (0.92 sec)
使用 insert 命令在表中插入一些记录:
mysql> insert into DemoTable711 values(100, 'Chris');
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable711 values(101, 'Robert');
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable711 values(102, 'Carol');
Query OK, 1 row affected (0.35 sec)
mysql> insert into DemoTable711 values(103, 'Mike');
Query OK, 1 row affected (0.17 sec)
mysql> insert ... 阅读更多