【发布时间】:2015-07-06 12:19:56
【问题描述】:
我有这个查询,但我无法连接第二列。
SELECT
Container.UIDaughterPlateId AS UIDaughterPlateId,
AllLastOperationInfo.OperationShortLabel AS lab
FROM
((InSite.UIDaughterPlate AS Container
INNER JOIN
InSite.UIDaughterPlateInfo AS UIDaughterPlateInfo ON (Container.UIDaughterPlateInfoId = UIDaughterPlateInfo.UIDaughterPlateInfoId ))
LEFT OUTER JOIN
(SELECT
UIOperationInfo.UIOperationInfoId as OperationInfoId,
UIOperationInfo.ParentId as DaughterPlateInfoId,
UIOperationInfo.Status as Status,
Operation.ShortLabel as OperationShortLabel,
UIOperationInfo.IsLast
FROM
UIOperationInfo
INNER JOIN
Operation ON Operation.OperationId = UIOperationInfo.UIOperationId
WHERE
UIOperationInfo.IsLast = 1 and Status = 'A Réaliser') AllLastOperationInfo ON (UIDaughterPlateInfo.UIDaughterPlateInfoId = AllLastOperationInfo.DaughterPlateInfoId ))
ORDER BY
Container.UIDaughterPlateName DESC
目前的结果是
-------------------------
| UIDaughterPlateId | Lab |
|-------------------------|
| 42 | MD |
| 42 | MC |
| 47 | MC |
| 67 | MA |
| 67 | MB |
| 67 | MC |
-------------------------
我想要这些结果
-------------------------------
| UIDaughterPlateId | Lab |
|-------------------------------|
| 42 | MC MD |
| 47 | MC |
| 67 | MA MB MC |
-------------------------------
我尝试了几个在其他帖子中找到的示例,但均未成功。
有人可以帮我吗?
谢谢
【问题讨论】:
-
我在下面提供了我的答案。你用吧。它也包含演示数据。您只需使用在 cmets 中看到的
SELECT。只需将#temp替换为您的表格即可。