找到 4379 篇文章 关于 MySQL
541 次浏览
以下是语法:update yourTableName set yourColumnName1= yourValue where yourColumnName2=yourValue order by yourColumnName2 DESC LIMIT 1;让我们首先创建一个表:mysql> create table DemoTable -> ( -> Id int, -> Name varchar(100) -> ); Query OK, 0 rows affected (0.61 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values(1, 'John'); Query OK, 1 row affected (0.41 sec) mysql> insert into DemoTable values(2, 'Chris'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(2, 'Robert'); Query OK, 1 row affected (0.14 sec) mysql> insert into ... 阅读更多
119 次浏览
以下是语法:show create view yourViewName;让我们首先创建一个表:mysql> create table DemoTable -> ( -> StudentName varchar(20) -> ); Query OK, 0 rows affected (0.56 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('Chris'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Robert'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('David'); Query OK, 1 row affected (0.13 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable;输出这将产生以下输出:+-------------+ | StudentName | +-------------+ | ... 阅读更多
209 次浏览
为此,您可以使用 INSERT()。让我们首先创建一个表:mysql> create table DemoTable -> ( -> ZipCode varchar(200) -> ); Query OK, 0 rows affected (0.47 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('9030'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('3902'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('9083'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('9089'); Query OK, 1 row affected (0.13 sec)使用 select 语句显示表中的所有记录 ... 阅读更多
440 次浏览
为此,使用 LENGTH()。让我们首先创建一个表:mysql> create table DemoTable -> ( -> Value text -> ); Query OK, 0 rows affected (0.74 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('10, 20, 10, 30, 10, 40, 50, 40'); Query OK, 1 row affected (0.24 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable;输出这将产生以下输出:+-------------------------+ | Value | +-------------------------+ | 10, 20, 10, 30, ... 阅读更多
195 次浏览
为此,使用 ALTER 命令。让我们首先创建一个表:mysql> create table DemoTable -> ( -> StudentName varchar(100) -> ); Query OK, 0 rows affected (0.46 sec)以下是插入 auto_increment 的查询:mysql> alter table DemoTable ADD COLUMN StudentId int NOT NULL; Query OK, 0 rows affected (0.50 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> alter table DemoTable ADD PRIMARY KEY(StudentId); Query OK, 0 rows affected (1.23 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> alter table DemoTable CHANGE StudentId StudentId int NOT NULL AUTO_INCREMENT; Query OK, 0 rows affected (2.20 sec) Records: 0 ... 阅读更多
205 次浏览
TYPE=HEAP 在较新的 MySQL 版本中已弃用。您可以使用 ENGINE=HEAP 代替 TYPE。以下是语法:ENGINE=HEAP;让我们创建一个表。在这里,我们设置了 Engine=HEAP:mysql> create TEMPORARY table DemoTable -> ( -> StudentId int, -> StudentName varchar(30) -> )Engine = HEAP; Query OK, 0 rows affected (0.00 sec)让我们检查表的定义:mysql> show create table DemoTable;输出这将产生以下输出:+--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | DemoTable | CREATE TEMPORARY TABLE `DemoTable` (`StudentId` int(11) DEFAULT NULL, `StudentName` varchar(30) COLLATE utf8_unicode_ci DEFAULT ... 阅读更多
70 次浏览
让我们首先创建一个表:mysql> create table DemoTable -> ( -> Number int -> ); Query OK, 0 rows affected (0.58 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values(9); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(4); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable values(0); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(7); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(11); Query OK, 1 row affected (0.12 sec)显示所有 ... 阅读更多
842 次浏览
要按时间戳排序,请使用 ORDER BY,如下面的语法所示:select *from yourTableName ORDER BY STR_TO_DATE(`yourColumnName`, '%m/%d/%Y%h:%i:%s %p');让我们首先创建一个表:mysql> create table DemoTable -> ( -> `timestamp` varchar(100) -> ); Query OK, 0 rows affected (0.56 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('06/22/2019 01:10:20 PM'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('06/22/2019 12:00:27 PM'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values('06/22/2019 06:56:20 AM'); Query OK, 1 row affected (0.23 sec) ... 阅读更多
3K+ 次浏览
要基于条件设置值,请使用 IF() 方法。让我们首先创建一个表:mysql> create table DemoTable -> ( -> Age int -> ); Query OK, 0 rows affected (0.55 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values(19); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values(16); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(17); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(22); Query OK, 1 row affected (0.19 sec)显示所有 ... 阅读更多
5K+ 次浏览
为此,使用 concat()。让我们首先创建一个表:mysql> create table DemoTable -> ( -> FirstName varchar(30), -> LastName varchar(30) -> ); Query OK, 0 rows affected (0.49 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable values('Chris', 'Brown'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('Adam', 'Smith'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('Carol', 'Taylor'); Query OK, 1 row affected (0.15 sec)使用 select 语句显示表中的所有记录:mysql> select *from DemoTable;输出这将产生以下 ... 阅读更多