簡體   English   中英

用於格式化GridView中DataSource的表數據的SQL查詢

[英]SQL query to format table data for DataSource in GridView

我正在尋找可以傳輸源SQL表數據的SQL Server查詢:

TextID | Text  | LanguageID
-------|-------|-------------------------------------
app.aa | Hi    | 6a13ea09-46ea-4c93-9b6a-e26bdc6ff4d8
app.cc | Hund  | 0c894bb7-4937-4903-906a-d1b1dd64935c
app.aa | Hallo | 0c894bb7-4937-4903-906a-d1b1dd64935c
app.cc | Dog   | 6a13ea09-46ea-4c93-9b6a-e26bdc6ff4d8
app.bb | Star  | 6a13ea09-46ea-4c93-9b6a-e26bdc6ff4d8
... 

像這樣的表:

TextID | Original | Translated
-------|----------|-----------
app.aa | Hi       | Hallo
app.bb | Star     | -
app.cc | Dog      | Hund
...

這樣我就可以在ASP .NET中將它用作GridView的DataSource。 預先感謝您的幫助。

每當您需要將來自兩個不同行的數據合並為一個時,您需要加入 例如:

select src.TextID "TextID", src.Text "Original", tr.Text "Translated"
from source_table src
left join source_table tr
on src.TextID = tr.TextID
and src.LangID = 'xxx'  -- xxx is the source language id
and tr.LangID = 'yyy' -- yyy is the target language id

左連接確保未翻譯的單詞包含空翻譯值。 要為DataSource創建一個表,您需要在select周圍包裝create table (或者創建視圖 ):

create table translations as
    select ...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM