5

我有两个单列表。即类型和 URL 这些是

items
-----
image
image
image
video

items
-----
http://photo.com/some.jpg
http://photo.com/some1.jpg
http://photo.com/some2.jpg
http://video.com/some.avi

我想要结果为

    Type                     URL
    -----------------------------
    image                    http://photo.com/some.jpg
    image                    http://photo.com/some1.jpg
    image                    http://photo.com/some2.jpg
    video                    http://video.com/some.avi

我怎样才能在这里得到结果类型和 url 表没有初级键列

4

1 回答 1

3

你可以在这里找到你的解决方案

下面是详细信息

CREATE TABLE T1 (
    items VARCHAR(10)
)
CREATE TABLE T2 (
    items VARCHAR(100)
)
INSERT INTO T1
VALUES ('image'),('image'),('image'),('video')

INSERT INTO T2
VALUES ('http://photo.com/some.jpg'),('http://photo.com/some1.jpg'),('http://photo.com/some2.jpg'),('http://video.com/some.avi')


select TT1.t1_items as Type,TT2.t2_items as URL from 
(select items t1_items,row_number() over(order by (SELECT 0)) as t1r from t1) as TT1,
(select items t2_items,row_number() over(order by (SELECT 0)) as t2r from t2) as TT2
where TT1.t1r = TT2.t2r
于 2013-06-05T06:44:43.243 回答