让我们首先创建一个表-
mysql> create table DemoTable622 (Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,Value1 int,Value2 int);
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable622(Value1,Value2) values(1000,1000); mysql> insert into DemoTable622(Value1,Value2) values(2000,3000);
使用select语句显示表中的所有记录-
mysql> select *from DemoTable622;
这将产生以下输出-
+----+--------+--------+ | Id | Value1 | Value2 | +----+--------+--------+ | 1 | 1000 | 1000 | | 2 | 2000 | 3000 | +----+--------+--------+ 2 rows in set (0.00 sec)
这是对MySQL组合的查询-
mysql> select tbl1.Id,tbl2.Value1,tbl3.Value2 from DemoTable622 tbl1,DemoTable622 tbl2,DemoTable622 tbl3;
这将产生以下输出-
+----+--------+--------+ | Id | Value1 | Value2 | +----+--------+--------+ | 1 | 1000 | 1000 | | 2 | 1000 | 1000 | | 1 | 2000 | 1000 | | 2 | 2000 | 1000 | | 1 | 1000 | 3000 | | 2 | 1000 | 3000 | | 1 | 2000 | 3000 | | 2 | 2000 | 3000 | +----+--------+--------+ 8 rows in set (0.01 sec)