我有以下查詢:SQL子查詢
SELECT id, subject, date
FROM mail
WHERE date > some_date
我需要交叉參考上述查詢與另一個表返回的ID來獲得用戶的用戶名。我怎樣才能在一個查詢中做到這一點?
現在我這樣做:
foreach (id in result)
{
query = String.Format("SELECT username from USERS where id = {0}", id);
}
預計列輸出:
id subject date username
--------------------------------
爲了澄清,你想運行一個查詢來獲取'MAIL.id','MAIL.subject','MAIL.date'和'USERS .username'? – 2010-09-08 00:38:10
@OMG Ponies yes – Arizona1911 2010-09-08 00:40:50