找到 4219 篇文章 关于 MySQLi
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 ... 阅读更多
1K+ 次浏览
为此,您可以将 IN() 与 ORDER BY FIELD() 一起使用。让我们首先创建一个表 −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(100) ); Query OK, 0 rows affected (0.64 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable(FirstName) values('Chris'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable(FirstName) values('Robert'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable(FirstName) values('Mike'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(FirstName) values('Sam'); Query OK, 1 row affected (0.12 sec) mysql> insert into ... 阅读更多
443 次浏览
使用 information_schema.tables 来显示所有表。同时设置数据库名称,以便您可以仅显示来自特定数据库的表。现在让我们显示“web”数据库中的所有表 −mysql> select group_concat(table_name) from information_schema.tables where table_schema='web';这将产生以下输出 −+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | group_concat(table_name) | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | demo_table725, demotabe619, demotabe620, demotable211, demotable212, demotable213, demotable214, demotable215, demotable216, demotable217, demotable218, demotable219, demotable220, demotable221, demotable222, demotable223, demotable224, demotable225, demotable226, demotable227, demotable228, demotable229, demotable230, demotable231, demotable232, demotable233, demotable234, demotable235, demotable236, demotable237, demotable238, demotable239, demotable240, demotable241, demotable244, demotable245, demotable246, demotable247, demotable248, demotable249, demotable250, demotable251, demotable252, demotable 253, demotable254, ... 阅读更多
191 次浏览
让我们首先创建一个表 −mysql> create table DemoTable ( Title text ); Query OK, 0 rows affected (0.86 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable values('C is a good programming language to start'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('Java is good with data structure and algorithm'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('Coding is very important'); Query OK, 1 row affected (0.20 sec)使用 select 语句显示表中的所有记录 −mysql> select *from DemoTable;这将产生以下输出 ... 阅读更多
66 次浏览
让我们首先创建一个表 −mysql> create table DemoTable ( Id int, FirstName varchar(100) ); Query OK, 0 rows affected (0.69 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable values(100, 'Chris'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(100, 'Robert'); Query OK, 1 row affected (0.48 sec) mysql> insert into DemoTable values(100, 'Mike'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values(100, 'Sam'); Query OK, 1 row affected (0.48 sec) mysql> insert into DemoTable values(101, 'David'); Query OK, 1 row affected (0.19 sec) mysql> insert ... 阅读更多
201 次浏览
是的,我们可以使用反引号将下划线作为表名。以下是语法:INSERT INTO `yourTableName` values(yourValue1, .......N); 让我们先创建一个表: mysql> create table `DemoTable_1` ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Location varchar(100) ); Query OK, 0 rows affected (1.17 sec) 使用insert命令在表中插入一些记录: mysql> insert into `DemoTable_1`(Location) values('C:/myFolder/JavaFiles'); Query OK, 1 row affected (0.20 sec) mysql> insert into `DemoTable_1`(Location) values('E:/AllJarOfJava'); Query OK, 1 row affected (0.17 sec) mysql> insert into `DemoTable_1`(Location) values('C:/ProgramFiles'); Query OK, 1 row affected (0.17 sec) 从…显示所有记录 阅读更多