您好我想從LEAD2複製到LEAD1。我有查詢選擇這些列,但我不知道如何更新set LEAD2=LEAD1
。以下是選擇查詢:在內部連接的SQL更新和
SELECT
a.lead_id AS LEAD1
, b.lead_id AS LEAD2
FROM
dbo.spirulina AS a
INNER JOIN dbo.spirulina AS b
ON a.PHONEHOME = b.PHONEHOME
WHERE
(a.lead_id IS NOT NULL)
AND (b.lead_id IS NULL)
GROUP BY
a.lead_id
, b.lead_id
HAVING
(COUNT(a.PHONEHOME) > 1)
你能描述究竟是什麼你想在這裏做什麼?因爲可能有一種簡單的方法來實現您可能試圖通過此查詢來實現的內容。 – singhsac
看起來像你想設置lead_id爲null當一個phonehome在多行? – dotjoe
@dotjoe對不起我的錯。 lead2 = lead1 ... no lead1 = lead2 –