久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

用不同的列名堆疊兩個 sql 表 (2008)

stacking two sql tables (2008) with different column names(用不同的列名堆疊兩個 sql 表 (2008))
本文介紹了用不同的列名堆疊兩個 sql 表 (2008)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我檢查了這個站點的代碼來堆疊兩個表(將一個表的結果放在另一個表的結果下方),其中列名不同.我知道當名稱相同時 UNION ALL 有效..而且我知道 UNION ALL 對一個表中缺少的列名進行分配時,當一個表比另一個表具有更多信息時會起作用..但是如果該列會怎樣名字不一樣?就像如果在一張表中的列名稱是 CHP 而在另一張表中它是CHILD HEALTH PLUS"并且我需要將這兩列堆疊在一起會怎樣?

I checked this site for code to stack two tables (put the results from one table beneath the results from another) where the column names are different. I know that UNION ALL works when the names are the same.. and I KNOW THAT UNION ALL with an assignment for the column names that are missing from one table works when one table has more info than the other.. but what if the column names are different? like what if in one table the column name is CHP and in another it is "CHILD HEALTH PLUS" and I need those two columns to be stacked on top of one another?

推薦答案

只要列的數據類型相同,就可以使用 UNION.列名是否不同并不重要.

A UNION can be used as long as the datatypes of the columns are the same. It doesn't matter if the column names are different.

SELECT column1
FROM Table1
UNION
SELECT column1
FROM Table2

如果你想知道記錄來自哪個表,那么你可以添加另一個字段來區分行:

If you want to know which table the records are coming from, then you can add another field that will distinguish the rows:

SELECT column1, 'Table1' as TableName
FROM Table1
UNION
SELECT column1, 'Table2' as TableName
FROM Table2

這篇關于用不同的列名堆疊兩個 sql 表 (2008)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

What SQL Server Datatype Should I Use To Store A Byte[](我應該使用什么 SQL Server 數據類型來存儲字節 [])
Interpreting type codes in sys.objects in SQL Server(解釋 SQL Server 中 sys.objects 中的類型代碼)
Typeorm Does not return all data(Typeorm 不返回所有數據)
Typeorm .loadRelationCountAndMap returns zeros(Typeorm .loadRelationCountAndMap 返回零)
How to convert #39;2016-07-01 01:12:22 PM#39; to #39;2016-07-01 13:12:22#39; hour format?(如何將“2016-07-01 01:12:22 PM轉換為“2016-07-01 13:12:22小時格式?)
MS SQL: Should ISDATE() Return quot;1quot; when Cannot Cast as Date?(MS SQL:ISDATE() 是否應該返回“1?什么時候不能投射為日期?)
主站蜘蛛池模板: 精品一区二区三区91 | 欧美激情 一区 | 久久精品国产亚洲a | 久久久婷| 欧美黄在线观看 | 欧美极品视频 | 福利视频亚洲 | 久久免费高清视频 | 国产精品久久久久aaaa九色 | 国产午夜精品一区二区三区嫩草 | 在线电影日韩 | 91麻豆精品国产91久久久更新资源速度超快 | 国外成人在线视频 | 国产精品二区三区在线观看 | 国产视频观看 | 欧美福利视频一区 | 1级毛片| 久久青青 | 日韩精品视频在线播放 | 欧美一区二区免费 | 中文字幕二区三区 | 欧洲亚洲精品久久久久 | 日韩精品免费在线观看 | 狠狠操狠狠搞 | 亚洲成人中文字幕 | 久久久www成人免费无遮挡大片 | 台湾a级理论片在线观看 | 欧美一区二区三区 | 成人精品鲁一区一区二区 | 中文字幕精品一区二区三区在线 | 久久精品亚洲欧美日韩久久 | 色欧美片视频在线观看 | 91国语清晰打电话对白 | 国产成人免费视频 | 国产精品综合 | 免费久久网站 | 欧美影院| 亚洲视频一区在线观看 | 亚洲一区二区三区免费在线观看 | 亚洲精品不卡 | www.久久久久久久久久久 |