我有两个单列表。即类型和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表没有质量键列
答案 0 :(得分:3)
您可以找到解决方案Here
以下是详细信息
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