2013-05-13 68 views

回答

5

嘗試這樣的....但要確保你的select ncount回報單列.....如果不是將選擇最上面一行ncount

SELECT TOP(SELECT TOP 1 nCOUNT FROM myAnotherTable WHERE ID = @id) * FROM mytable WHERE ID = @id 

SqlFiddle:http://www.sqlfiddle.com/#!3/75c76/1

+0

要確保當SELECT nCount ...返回多於一行時,您的嘗試不會遇到錯誤,請限制輸出:SELECT TOP 1 nCount ...。 – alzaimar 2013-05-13 05:36:08

+0

@alzaimar感謝您的好建議...我按照您的建議編輯了... – 2013-05-13 05:43:33