找到 4379 篇文章 适用于 MySQL
202 次查看
让我们首先创建一个表 -mysql> create table DemoTable1460 -> ( -> Name varchar(20) -> ); Query OK, 0 rows affected (0.91 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1460 values('Chris'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1460 values('David'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1460 values('Bob'); Query OK, 1 row affected (0.52 sec) mysql> insert into DemoTable1460 values('Robert'); Query OK, 1 row affected (0.11 sec)使用 select 语句显示表中的所有记录 -mysql> select * from DemoTable1460;这将产生以下结果... 阅读更多
880 次查看
以下是创建第一个表的查询。mysql> create table DemoTable1 -> ( -> StudentName varchar(20), -> StudentMarks int -> ); Query OK, 0 rows affected (0.67 sec)为了理解上述概念,让我们创建第二个表。mysql> create table DemoTable2 -> ( -> Name varchar(20) -> ); Query OK, 0 rows affected (0.61 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable2 values('Chris'); Query OK, 1 row affected (0.12 sec)使用 select 语句显示表中的所有记录 -mysql> select * from DemoTable2;这将产生以下输出 -+-------+ ... 阅读更多
1K+ 次查看
使用 IS NOT NULL 查找非空值并显示它们。让我们首先创建一个表 -mysql> create table DemoTable1458 -> ( -> StudentName varchar(20), -> StudentScore int -> ); Query OK, 0 rows affected (0.52 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1458 values('Chris Brown', 56); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1458 values('David Miller', NULL); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1458 values('John Doe', 78); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable1458 values('Adam Smith', NULL); ... 阅读更多
700 次查看
要将时间戳转换为月份,请使用以下语法中的 FROM_UNIXTIME() 方法 -select month(from_unixtime(yourColumnName)) from yourTableName;让我们首先创建一个表 -mysql> create table DemoTable1457 -> ( -> Value bigint -> ); Query OK, 0 rows affected (0.85 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1457 values(1570207117); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable1457 values(1548947534); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1457 values(1575213134); Query OK, 1 row affected (0.13 sec)使用 select 语句显示表中的所有记录 -mysql> select * from ... 阅读更多
419 次查看
要执行 MySQL 在两个日期之间搜索,请使用 BETWEEN 关键字。让我们首先创建一个表 -mysql> create table DemoTable1456 -> ( -> CustomerName varchar(30), -> StartOfferDate date, -> EndOfferDate date -> ); Query OK, 0 rows affected (0.54 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1456 values('Chris', '2019-09-01', '2019-09-30'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1456 values('David', '2019-09-01', '2019-10-30'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1456 values('Bob', '2018-10-01', '2018-10-20'); Query OK, 1 row affected (0.15 sec)显示表中的所有记录 ... 阅读更多
66 次查看
要检查 SELECT 中的 NULL 值,请使用 MySQL NULL。让我们首先创建一个表 -mysql> create table DemoTable1455 -> ( -> Name varchar(20) -> ); Query OK, 0 rows affected (0.47 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1455 values('John'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable1455 values(NULL); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1455 values(''); Query OK, 1 row affected (0.19 sec)使用 select 语句显示表中的所有记录 -mysql> select * from DemoTable1455;这将产生以下输出 -+------+ ... 阅读更多
113 次查看
以下是语法 -select * from yourTableName order by ( yourColumnName> now()) desc, (case when yourColumnName > now() then yourColumnName end) , yourColumnName desc limit 1;让我们首先创建一个表 -mysql> create table DemoTable1454 -> ( -> ShippingDate date -> ); Query OK, 0 rows affected (0.59 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1454 values('2019-10-01'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable1454 values('2019-10-03'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable1454 values('2019-10-05'); Query OK, 1 row affected (0.25 sec) mysql> insert ... 阅读更多
159 次查看
让我们首先创建一个表 -mysql> create table DemoTable1453 -> ( -> CustomerId int, -> CustomerReviewNumber int -> ); Query OK, 0 rows affected (0.58 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable1453 values(10, 4); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1453 values(10, 4); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable1453 values(11, 5); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1453 values(11, 5); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable1453 values(11, 5); Query OK, 1 ... 阅读更多
640 次查看
首先,让我们创建一个表 -mysql> create table DemoTable1452 -> ( -> FavouriteColor varchar(50) -> ); Query OK, 0 rows affected (2.42 sec)使用insert命令在表中插入一些记录 -mysql> insert into DemoTable1452 values('Red'); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable1452 values('Yellow'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1452 values('Yellow'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1452 values('Yellow'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable1452 values('Blue'); Query OK, 1 row affected (0.42 sec) mysql> insert into DemoTable1452 values('Blue'); ... 阅读更多