假設我有一個SQL查詢是這樣的:SQL:連接所有匹配給定鍵的字段?
SELECT
tickets.TicketNumber, history.remarks
FROM
AT_DeviceReplacement_Tickets tickets
INNER JOIN
AT_DeviceReplacement_Tickets_History history
ON tickets.TicketNumber = history.TicketNumber;
我得到一個表像這樣repsonse:
ticketNumber | remarks
-------------+------------
1 | "Hello, there is a problem."
1 | "Did you check the power cable?
1 | "We plugged it in and now it works. Thank you!"
2 | "Hello, this is a new ticket."
假設我要編寫一個查詢,將串連的言論每張機票並返回一個表是這樣的:
ticketNumber | remarks
-------------+------------
1 | "Hello, there is a problem.Did you check the power cable?We plugged it in and now it works. Thank you!"
2 | "Hello, this is a new ticket."
是的,在實際的代碼,我實際上已經通過了這些日期排序,除其他事項外,只是爲求討論,我將如何編輯上述查詢以獲得我描述的結果?
我猜我需要使用某種'GROUP BY'魔法。 – 2011-04-27 18:13:31