假设我有一个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