情况是这样:
现在有,t1 ,t2 ,t3,t4.....t10
一共10张表
他们的连接条件是:
t1.xxx = t2.xxx
t2.aaa = t4.aaa
t5.ooo  = t10.ooo
....过滤条件是
t1.id  = 100
t2.date < 201004
....这样的需求应该怎么写呢?
我之前写的是
select * from t1 
join t2
join t3
...
on t1.xxx = t2.xx
...
where t1.id = 100
...这样好像不对,请教下,如果遇到大于2张表的联合查询,应该怎么写?

解决方案 »

  1.   

    select* from(两张表联合查询的结果)inner join **on**
      

  2.   

    1、直接=连接
    select * from t1 ,t2 ,t3,t4.....t10 where 
    t1.xxx = t2.xxx
    t2.aaa = t4.aaa
    t5.ooo = t10.ooo
    .....;
    2、join
    select * from t1  
    join t2 on (t1.xxx = t2.xxx) join t3 on (1=1) join t4 on (t2=t4) join ....;
      

  3.   

    情况是每张表基本都和其他表有关联,我意思通过join或者left join 怎么写?
      

  4.   

    奥 了解了,我把连接条件统统写一起了,谢谢tangren 我先测试下
      

  5.   

    很厉害啊。羡慕ing。
    转个跑腿分。