找到 4379 篇文章 关于 MySQL
292 次查看
让我们先创建一个表 -mysql> create table DemoTable -> ( -> FirstName varchar(100) -> ); Query OK, 0 rows affected (0.53 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Adam'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Sam'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values('Johnny'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('Joy'); Query OK, 1 row affected (0.12 sec) ... 阅读更多
2K+ 次查看
您可以使用格式说明符。以下是语法 -select str_to_date(yourColumnName, '%d/%m/%Y %h:%i %p') as anyAliasName from yourTableName;让我们先创建一个表 -mysql> create table DemoTable -> ( -> DueDate varchar(100) -> ); Query OK, 0 rows affected (0.51 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('11/02/2019 10:35'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('21/12/2018 12:01'); Query OK, 1 row affected (0.19 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable;输出这将产生以下输出 -+------------------+ | DueDate ... 阅读更多
825 次查看
为此,您可以使用 REGEXP。让我们先创建一个表 -mysql> create table DemoTable -> ( -> ClientCode varchar(100) -> ); Query OK, 0 rows affected (0.56 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('Chris902'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('Robert_'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('903'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('123_David'); Query OK, 1 row affected (0.21 sec)使用 select 语句显示表中的所有记录 ... 阅读更多
521 次查看
对于精确区分大小写的匹配,在 MySQL 中的 WHERE 子句后使用 BINARY。让我们先创建一个表 -mysql> create table DemoTable -> ( -> EmployeeCode varchar(100) -> ); Query OK, 0 rows affected (0.64 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('EMP-1122'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('emp-1122'); Query OK, 1 row affected (0.43 sec) mysql> insert into DemoTable values('EMP-6756'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('EMP-8775'); Query OK, 1 row affected (0.16 sec)显示所有记录 ... 阅读更多
1K+ 次查看
是的,我们可以通过首先使用 CAST() 来做到这一点。让我们先创建一个表 -mysql> create table DemoTable -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentScore varchar(100) -> ); Query OK, 0 rows affected (0.66 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable(StudentScore) values('90'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(StudentScore) values('100'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(StudentScore) values('56'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(StudentScore) values('98'); Query OK, 1 ... 阅读更多
97 次查看
让我们先创建一个表 -mysql> create table DemoTable -> ( -> Value int -> ); Query OK, 0 rows affected (0.80 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.14 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable;输出这将产生以下输出 -+-------+ | Value | +-------+ | 10 | | ... 阅读更多
128 次查看
让我们先创建一个表 -mysql> create table DemoTable -> ( -> Id int, -> Value int -> ); Query OK, 0 rows affected (0.68 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values(100, 85885); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(101, 885995474); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(100, 895943); Query OK, 1 row affected (0.20 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable;输出这将产生以下输出 -+------+-----------+ | Id ... 阅读更多
218 次查看
让我们先创建一个表 -mysql> create table DemoTable -> ( -> ArrivalDate datetime -> ); Query OK, 0 rows affected (0.91 sec)使用 insert 命令在表中插入一些记录。假设当前日期为 2019-07-03 -mysql> insert into DemoTable values('2019-07-03'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('2019-06-20'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('2019-06-15'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('2018-06-11'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('2018-06-01'); Query ... 阅读更多
1K+ 次查看
要显示表的结构,以下是语法 -show create table yourTableName;让我们先创建一个表 -mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> EmployeeFirstName varchar(100), -> EmployeeLastName varchar(100), -> EmployeeAge int, -> isMarried tinyint(1), -> EmployeeAddress varchar(100), -> EmployeeCountryName varchar(100) -> ); Query OK, 0 rows affected (0.62 sec)以下是显示结构的查询 -mysql> show create table DemoTable;输出这将产生以下输出 -+--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table ... 阅读更多
108 次查看
使用 CASE 语句并为其设置条件。让我们先创建一个表 -mysql> create table DemoTable -> ( -> X int, -> Y int -> ); Query OK, 0 rows affected (0.57 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values(20, 30); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(40, 15); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(80, 85); Query OK, 1 row affected (0.13 sec)使用 select 语句显示表中的所有记录 -mysql> select ... 阅读更多