SELECT
person.bu_id,
key.key_val,
obj_person_add.person_contact_freq,
obj_person_add.person_contact_best,
OBJ_PERSON_ADD.PERSON_CONTACT_INST,
OBJ_PERSON_ADD.PERSON_CONTACT_DATE,
OBJ_PERSON_ADD.PERSON_BROCHURES,
OBJ_PERSON_ADD.PERSON_NEWSLETTER
FROM obj_person person
INNER JOIN obj_person_add
ON person.obj_id = obj_person_add.obj_id
LEFT JOIN obj_rel_key key
ON key.obj_id = person.obj_id
WHERE person.bu_id in (6,7)
AND person.close_date IS NULL
AND key.obj_key_id = 806
AND (
obj_person_add.person_contact_freq IS NOT NULL
OR obj_person_add.person_contact_best IS NOT NULL
OR OBJ_PERSON_ADD.PERSON_CONTACT_INST IS NOT NULL
OR OBJ_PERSON_ADD.PERSON_CONTACT_DATE IS NOT NULL
OR OBJ_PERSON_ADD.PERSON_BROCHURES IS NOT NULL
OR OBJ_PERSON_ADD.PERSON_NEWSLETTER IS NOT NULL
);
我已經建立了這個查詢,但是person_brochures和person_newsletters存儲在一個var數組中。這意味着他們返回(例如6172,6544 ...)。我想做一個左連接來將var數組中的ID與另一個表中的名稱進行匹配。如何加入var數組值
我是否必須循環var數組,然後以某種方式匹配ID的呢?
這是Oracle企業數據庫還是MySQL? – Mureinik
是的,我正在使用Oracle。 –