找到 4379 篇文章 关于 MySQL
132 次查看
您可以使用 ORDER BY TRIM()。让我们首先创建一个表 -mysql> create table DemoTable -> ( -> Title text -> ); Query OK, 0 rows affected (1.09 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('MongoDB is a no SQL database'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('The MySQL is a relational database'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values('The Java language is good'); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable values('Python is good language'); Query ... 阅读更多
321 次查看
要仅替换单个字符,请在 MySQL 中使用 REPLACE()。让我们首先创建一个表 -mysql> create table DemoTable -> ( -> Name varchar(20) -> ); Query OK, 0 rows affected (0.69 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('John Smitk'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('David Miller'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Adam Smitk'); Query OK, 1 row affected (0.11 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable;这将产生以下 ... 阅读更多
68 次查看
为此,您可以使用 ORDER BY IFNULL()。让我们首先创建一个表 -mysql> create table DemoTable -> ( -> Name varchar(20), -> CountryName varchar(20) -> ); Query OK, 0 rows affected (0.61 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('Chris', NULL); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('David', 'AUS'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(NULL, 'UK'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(NULL, 'AUS'); Query OK, 1 row affected (0.10 sec) mysql> ... 阅读更多
1K+ 次查看
为此,您可以在 PROCEDURE 中使用 UPDATE 命令以及 WHERE 子句。让我们首先创建一个表 -mysql> create table DemoTable -> ( -> Id int, -> FirstName varchar(20), -> LastName varchar(20) -> ); Query OK, 0 rows affected (0.56 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values(101, 'David', 'Brown'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(102, 'Chris', 'Brown'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable values(103, 'John', 'Doe'); Query OK, 1 row affected (0.07 ... 阅读更多
227 次查看
如果我们在 INSERT 语句中不插入任何内容,那么对于时间戳类型,它将插入当前日期时间。让我们首先创建一个表 -mysql> create table DemoTable -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserLoginDate timestamp default current_timestamp -> ); Query OK, 0 rows affected (0.61 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values(); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.08 ... 阅读更多
121 次查看
让我们首先创建一个表 -mysql> create table DemoTable -> ( -> Value varchar(20) -> ); Query OK, 0 rows affected (0.53 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('20'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('10.5'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('11'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('10'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('20.5'); Query OK, 1 row affected (0.13 sec)显示表中的所有记录 ... 阅读更多
201 次查看
使用 STR_TO_DATE() 方法插入日期记录,如下面的语法所示 -select str_to_date(yourColumnName, '%b %Y') from yourTableName;让我们首先创建一个表 -mysql> create table DemoTable -> ( -> JoiningYear varchar(20) -> ); Query OK, 0 rows affected (0.69 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('Jan 2018'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('May 2107'); Query OK, 1 row affected (0.32 sec) mysql> insert into DemoTable values('Aug 2019'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('Oct 2020'); Query OK, ... 阅读更多
95 次查看
让我们首先创建一个表 -mysql> create table DemoTable -> ( -> Version varchar(20) -> ); Query OK, 0 rows affected (0.77 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('1.0.0'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('2.s6.9'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('1.5.0'); Query OK, 1 row affected (0.12 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable;这将产生以下输出 -+---------+ | Version | +---------+ | 1.0.0 | | 2.s6.9 | ... 阅读更多
220 次查看
在 MySQL 中使用 FORMAT() 函数来显示货币记录并以正确的格式显示它们。让我们首先创建一个表 -mysql> create table DemoTable -> ( -> Amount DECIMAL(15, 4) -> ); Query OK, 0 rows affected (0.75 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values(90948484); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(1000000000); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(1535353536); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values(773646463); Query OK, 1 row affected (0.20 sec)显示所有 ... 阅读更多