久久久久久久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?什么時候不能投射為日期?)
主站蜘蛛池模板: 午夜欧美| 狠狠操av | 色av一区二区三区 | 在线观看www视频 | 三级免费 | 视频一区在线观看 | 日韩电影在线 | 国产精品一区一区三区 | 日日夜夜精品免费视频 | 亚洲欧美日韩精品久久亚洲区 | 国产成人久久 | 欧美激情视频一区二区三区在线播放 | 日韩精品在线视频免费观看 | 精品粉嫩超白一线天av | 色婷婷av777 av免费网站在线 | 精品成人免费视频 | 羞羞色影院 | 日韩精品999 | 欧美精品久久久久 | 毛片韩国 | 日韩中文字幕视频在线观看 | 成人性视频免费网站 | 综合在线视频 | 国产一级久久久久 | 国产亚洲欧美日韩精品一区二区三区 | 免费激情 | 日韩有码一区二区三区 | 婷婷色国产偷v国产偷v小说 | 亚洲区视频| av国产精品| 天天看逼| www.久久.com | 日韩欧美久久 | 神马影院一区二区三区 | 日韩视频区 | 国产伦精品一区二区三区视频金莲 | 日韩成人免费中文字幕 | 极品久久 | 成人亚洲 | 成人夜晚看av | av国产精品 |