UserID Manufactor Country Model Time to et Engine CC PriceS$
100001188587932 vsd dsv 3 Series 2012 2011          10000
100001188587932 fsd fs 3 Series 2012 2010          50000
100001188587932 BMW German 3 Series 2012 2012            0
100001188587932 BMW 3 Series 2012 2004            0
100001188587932 BMW German 3 Series 2012 2006            0其中Manufactor,Country和Model是一个table的.
而Time , Engine 和Price 又是另一个table的.
如何把他们合并在一起呢?

解决方案 »

  1.   

    这两个表需要有链接的列,假如链接列是 UserIDselect UserID,Manufactor,Country, Time , Engine, Price
    from table1
    inner join table2 on table1.UserID = table2.UserID
      

  2.   

    如果毫无关联,就用cross join,但是结果集会猛增,要考虑设计是否有问题。
      

  3.   


    --如果UserID关联
    select UserID,Manufactor,Country, Time , Engine, Price
    from tab1
    inner join tab2 on tab1.UserID = tab2.UserID--如果没有关联select UserID,Manufactor,Country, Time , Engine, Price
    from tab1
    cross join tab2 
    --注意如果tab1\tab2数据量大,cross join 
    将以笛卡尔积的形式将表的所有记录一一连接,结果集数据量将会剧增
      

  4.   

    select t1.*,t2.*
    from table1 as t1
    cross join table2 as t2
      

  5.   

    1楼 用过你的了 但是没有显示 2楼 我已经改了table userID是关联.
      

  6.   

    cross join都没用过,长见识了。一般都是有关联的才join