1
我目前在MySQL查詢中單獨使用coallescing字段,但我想合併整個記錄。在MySQL中合併整個記錄
這可能嗎?
SELECT la.id,
COALESCE((SELECT name FROM lookup_changed l0,
(SELECT MAX(id) id
FROM lookup_changed
WHERE lookup_id = 26
) l1
WHERE l0.id = l1.id
), la.name) name,
COALESCE((SELECT msisdn FROM lookup_changed l0,
(SELECT MAX(id) id
FROM lookup_changed
WHERE lookup_id = 26
) l1
WHERE l0.id = l1.id
), la.msisdn) msisdn
FROM lookup_added la
WHERE la.id = 26
@Alma執行 - 僞SQL是:
SELECT la.id,
MULTICOALESCE((SELECT <name, msisdn> FROM lookup_changed l0,
(SELECT MAX(id) id
FROM lookup_changed
WHERE lookup_id = 26
) l1
WHERE l0.id = l1.id
), <la.name, la.msisdn>) <name, msisdn>
FROM lookup_added la
WHERE la.id = 26
我沒沒有意義。你能提供僞SQL嗎?(即它看起來應該如何) –
@AlmaDo補充說,謝謝。 – fadedbee