聲明我正在做一個查詢,從表中的行獲取數據,並把它同列下:SQL WHERE SELECT語句中
SELECT [t].*,
[d].[Description] AS [Name],
FROM [TrainerClass] AS [t] join [DescriptionTranslation] AS [d] on [t].[Code] = [d].[Code]
WHERE [d].[TableName] = 'TrainerClass' AND
[d].[FieldName] = 'Name' AND
[d].[Language] = 'en-EN';
這只是正常,但它返回一列。我想用更多的列獲得相同的結果,但我無法弄清楚如何使用WHERE語句來完成。我想實現的東西,如:
SELECT [t].*,
[d].[Description] AS [Name] WHERE [d].[FieldName] = 'Name',
[d].[Description] AS [Info] WHERE [d].[FieldName] = 'Info',
FROM [TrainerClass] AS [t] join [DescriptionTranslation] AS [d] on [t].[Code] = [d].[Code]
WHERE [d].[TableName] = 'TrainerClass' AND
[d].[Language] = 'en-EN';
我知道這是不是一個正確的語法,這就是爲什麼我問你如何得到這樣的結果。謝謝提前:)
編輯:
我不想要什麼:
我想要什麼:
(僅做示例一條記錄,應該有更多)
它看起來我的權利,但遺憾的是它不返回任何數據。沒有語法錯誤,但... –
嘗試執行'left join'而不是'join'(默認情況下爲內連接)。看看這是否給你提示你爲什麼沒有得到一個匹配。 –
我得到了同樣的結果... –