找到 4379 篇文章 相关 MySQL
986 次浏览
让我们首先创建一个表 - mysql> create table DemoTable1 ( PersonId int, Value int ); Query OK, 0 rows affected (0.64 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable1 values(100, 78); Query OK, 1 row affected (0.46 sec) mysql> insert into DemoTable1 values(101, 67); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1 values(102, 89); Query OK, 1 row affected (0.19 sec)使用 select 语句显示表中的所有记录 - mysql> select *from DemoTable1;这将产生以下输出 -+----------+-------+ | PersonId | Value | +----------+-------+ | 100 ... 阅读更多
105 次浏览
让我们首先创建一个表 - mysql> create table DemoTable ( FirstName varchar(100), CountryName varchar(100) ); Query OK, 0 rows affected (0.56 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('Adam', 'US'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('David', 'AUS'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Chris', 'UK'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('John', 'US'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('Carol', 'AUS'); Query OK, 1 row affected (0.14 sec)显示所有记录 ... 阅读更多
991 次浏览
以下是使用 CREATE TABLE IF NOT EXISTS 检查表是否已存在的语法 - create table if not exists yourTableName ( yourColumnName1 dataType, . . . . N ); insert into yourTableName values(yourValue1, .......N);让我们首先创建一个表 - mysql> create table if not exists DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentSubject varchar(100) ); Query OK, 0 rows affected (0.60 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable(StudentSubject) values('Java'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable(StudentSubject) values('MySQL'); ... 阅读更多
108 次浏览
为此,您可以使用 FIND_IN_SET()。让我们首先创建一个表 - mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value varchar(100) ); Query OK, 0 rows affected (2.49 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable(Value) values('100;200;300'); Query OK, 1 row affected (0.42 sec) mysql> insert into DemoTable(Value) values('1;300;400'); Query OK, 1 row affected (0.58 sec) mysql> insert into DemoTable(Value) values('6;7;8;9;10'); Query OK, 1 row affected (0.29 sec) mysql> insert into DemoTable(Value) values('1;2;3;4;5'); Query OK, 1 row affected (9.36 sec) mysql> insert into DemoTable(Value) values('3;8;9;10'); Query OK, 1 ... 阅读更多
1K+ 次浏览
让我们首先创建一个表 &mnus;mysql> create table DemoTable ( `timestamp` timestamp ); Query OK, 0 rows affected (1.12 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values(now()); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable values('00:00:00'); Query OK, 1 row affected (0.73 sec) mysql> insert into DemoTable values('2018-01-10 12:34:45'); Query OK, 1 row affected (0.80 sec) mysql> insert into DemoTable values('2019-12-31 10:50:45'); Query OK, 1 row affected (0.84 sec)使用 select 语句显示表中的所有记录 - mysql> select *from DemoTable;这将产生以下输出 -+---------------------+ | timestamp ... 阅读更多
380 次浏览
为此,您可以将 replace() 与 group_concat() 结合使用。这里,对于空字段,我们显示逗号作为分隔符。让我们首先创建一个表 - mysql> create table DemoTable ( Id int, Number varchar(100) ); Query OK, 0 rows affected (2.03 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values(10, '456'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(11, '345'); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable values(10, ''); Query OK, 1 row affected (0.63 sec) mysql> insert into DemoTable values(10, '278'); Query ... 阅读更多
525 次浏览
为此,您可以将 ORDER BY DESC 与 LIMIT 结合使用。让我们首先创建一个表 - mysql> create table DemoTable ( UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, UserName varchar(100) ); Query OK, 0 rows affected (0.59 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable(UserName) values('Chris'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(UserName) values('Robert'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(UserName) values('Bob'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(UserName) values('David'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(UserName) ... 阅读更多
262 次浏览
让我们首先创建一个表 - mysql> create table DemoTable ( Name varchar(100) ); Query OK, 0 rows affected (0.60 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('John_Smith'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Chris Brown'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('John_Doe'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('David Miller'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('Carol Taylor'); Query OK, 1 row affected (0.13 sec)显示表中的所有记录使用 select ... 阅读更多
236 次浏览
为此,您可以将 DISTINCT 与 INSERT INTO SELECT 语句一起使用。让我们首先创建一个表 - mysql> create table DemoTable1 ( Value int ); Query OK, 0 rows affected (1.03 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable1 values(50); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1 values(10); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1 values(10); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1 values(60); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1 values(50); Query OK, 1 row ... 阅读更多
1K+ 次浏览
让我们首先创建一个表 - mysql> create table DemoTable ( UserId int, UserMessage varchar(100) ); Query OK, 0 rows affected (0.51 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values(1, 'Hi'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values(2, 'Hello'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(2, 'Good'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values(1, 'Nice'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(1, 'Awesome'); Query OK, 1 row affected (0.16 sec) mysql> insert ... 阅读更多