我有两个单列表.即类型和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
Run Code Online (Sandbox Code Playgroud)
我希望结果为
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
Run Code Online (Sandbox Code Playgroud)
我怎么能得到这里的结果类型和url表没有质量键列
我有Item和Sales表,有不同的列,比如
项目
ItemName
Itemcost
ItemQty
Run Code Online (Sandbox Code Playgroud)
销售
SalesName
SalesDate
SalesQty
Run Code Online (Sandbox Code Playgroud)
在上面的表中没有常见的列,但我需要输出为
ItemName,ItemCost,SalesName,SalesDate.
Run Code Online (Sandbox Code Playgroud)
我试过工会,
select ItemName,ItemCost from Item
union
select SalesName,SalesDate from Sales
Run Code Online (Sandbox Code Playgroud)
但我只获得了一个像ItemName,ItemCost这样的表列
请帮我解决这个问题
提前致谢
Venkat.
我想合并两个不同列的表 mysql。例如
表格1 :
-------------------------------------------------------------
item_id title slug type views updatedAt createdAt
-------------------------------------------------------------
1 sometitle someslg 1 43454 timestamp timestamp
2 sometitle someslg 1 43566 timestamp timestamp
Run Code Online (Sandbox Code Playgroud)
表 2:
-------------------------------------------------------------
id ptitle slug pviews updatedAt createdAt
-------------------------------------------------------------
1 sometitle someslg 3434 timestamp timestamp
2 sometitle someslg 6454 timestamp timestamp
3 sometitle someslg 5454 timestamp timestamp
Run Code Online (Sandbox Code Playgroud)
上表是示例。我已与UNION合并。这是我的查询
SELECT * ((SELECT t1.item_id,t1.title,t1.slug,t1.type,t1.views,t1.updatedAt,t1.createdAt
FROM table1
t1) UNION ALL (SELECT t2.id,t2.ptitle,t2.slug,'',t2.pviews,t2.updatedAt,t2.createdAt)) t3
ORDER BY t3.item_id ASC
Run Code Online (Sandbox Code Playgroud)
这工作正常执行查询后,我会得到类似的结果
-------------------------------------------------------------
item_id title slug type …Run Code Online (Sandbox Code Playgroud)