我有三个表:>>> example = dict_all(iterable)
#if iterable is the example dictionary above
#the result would be
>>> print(example)
(False, 'comp_type')
#which means
#example[0] is a Truthy or Falsey for the value in the key
#they key is example[1]
,mm_members
,cmn_addresses
在mm_member_statement_delivery_options
中,我有-> mm_members
,member_id
,member_number
列
在member_name
中,我有-> cmn_addresses
,reference_id
,reference_type
,email
列
并且这里address
与reference_id
在member_id
中,我有-> mm_member_statement_delivery_options
,member_id
我希望所有拥有statement_delivery_method
,member_numbers
且在mm_member_statement_delivery_options
中的statement_delivery_method IN(2,3)
都没有电子邮件,并且reference_type = 3 >
我在下面的查询中生成了这个,没有得到想要的结果
cmn_addresses
答案 0 :(得分:0)
Hope it will work for you :)
SELECT
DISTINCT mm_members.member_number AS MEMBER_NUMBER,
TRIM(CONCAT(mm_members.first_name,' ',mm_members.last_Name)) AS MEMBER_NAME,
cmn_addresses.email AS MEMBER_EMAIL,
mm_member_statement_delivery_options.statement_delivery_method
FROM mm_members
JOIN cmn_addresses ON cmn_addresses.reference_id = mm_members.member_id AND cmn_addresses.reference_type = 3
JOIN mm_member_statement_delivery_options ON mm_member_statement_delivery_options.member_id = mm_members.member_id
WHERE (cmn_addresses.email IS NULL OR cmn_addresses.email = '')
AND mm_member_statement_delivery_options.statement_delivery_method IN ('2','3')
ORDER BY MEMBER_NUMBER;