Объединить 2 записи в один
Я пытаюсь объединить 2 записи в одну, я видел несколько похожих вопросов, но они, кажется, не конкретная запись в БД
SELECT Summary1 as a, Summary2 as b, Summary3 as c, DateUpdated as d
FROM tbl_EC where id=1
SELECT Summary1 as e, Summary2 as f, Summary3 as g, DateUpdated as h
FROM tbl_EC where id=2
Любая помощь приветствуется!
1 ответ
Сделай сам присоединиться:
SELECT t1.Summary1 as a, t1.Summary2 as b, t1.Summary3 as c, t1.DateUpdated as d,
t2.Summary1 as e, t2.Summary2 as f, t2.Summary3 as g, t2.DateUpdated as h
FROM tbl_EC t1
JOIN tbl_EC t2 ON t1.id + 1 = t2.id
WHERE t1.ID = 1
Возможно, вы хотите перейти на FULL OUTER JOIN
, если какой-либо идентификатор может отсутствовать?
SELECT t1.Summary1 as a, t1.Summary2 as b, t1.Summary3 as c, t1.DateUpdated as d,
t2.Summary1 as e, t2.Summary2 as f, t2.Summary3 as g, t2.DateUpdated as h
FROM tbl_EC t1
FULL OUTER JOIN tbl_EC t2 ON t1.id + 1 = t2.id
and (t1.id % 2 = 1 or t2.id % 2 = 0)