mysql查询怪异问题

由于对数据库研究不是很深,最近在使用mysql时出现如下现象,做此笔记:
有test1 , test2 ,test3 三个表,表结构相同,分别有t1,t2两列,
数据如下:
test1
t1 t2
=========================================
a a1
b b1
c c1
==========================================
test2
t1 t2
=========================================
a a2
b b2
c c2
==============================================
test3
t1 t2
============================================
a a3
b b3
c c3
============================================

执行如下查询:
查询1:
select a.* , b.* from test1 a , test2 b
结果是test1,test2两表做笛卡尔乘绩,结果为:
test1.t1 test1.t2 test2.t1 test2.t2
a a1 a a2
b b1 a a2
c c1 a a2
a a1 b b2
b b1 b b2
c c1 b b2
a a1 c c2
b b1 c c2
c c1 c c2

查询2:
select a.*,b.*,c.* from test1 a , test2 b,test3 c where a.t1 =b.t1=c.t1 order by a.t1,b.t1
结果如下:
test1.t1 test1.t2 test2.t1 test2.t2 test3.t1 test3.t2
a a1 b b2 a a3
a a1 b b2 b b3
a a1 b b2 c c3
a a1 c c2 a a3
a a1 c c2 b b3
a a1 c c2 c c3
b b1 a a2 a a3
b b1 a a2 b b3
b b1 a a2 c c3
b b1 c c2 a a3
b b1 c c2 b b3
b b1 c c2 c c3
c c1 a a2 a a3
c c1 a a2 b b3
c c1 a a2 c c3
c c1 b b2 a a3
c c1 b b2 b b3
c c1 b b2 c c3
查询3:
select a.*,b.*,c.* from test1 a , test2 b,test3 c where a.t1 =b.t1 and b.t1=c.t1
结果如下:
test1.t1 test1.t2 test2.t1 test2.t2 test3.t1 test3.t2
a a1 a a2 a a3
b b1 b b2 b b3
c c1 c c2 c c3


上述三个查询,第一和第三个好理解。但第二个就有点不知所云了,mysql中做连等是不行的。具体原因等待高手来解决了。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值