在做一个邮件设置功能,由于数据库表设计者很蠢,导致查询起来很费劲,有的时候可能要将简单的查询根据条件不同执行很多次,很是让自己不开心。下面是一个与蠢人打交道的成功方案:
sql:
select
tmp1.host_address,tmp2.host_port,tmp3.email_user_name,
tmp4.email_password,tmp5.accept_email_address,tmp6.publicity_is_send
from
(select
wmsys.wm_concat (value) as host_address
from
t_sys_setup
where
data_type in ('mail_server'))tmp1,
(select
wmsys.wm_concat (value) as host_port
from
t_sys_setup
where
data_type in ('mail_port'))tmp2,
(select
wmsys.wm_concat (value) as email_user_name
from
t_sys_setup
where
data_type in ('mail_account'))tmp3,
(select
wmsys.wm_concat (value) as email_password
from
t_sys_setup
where
data_type in ('mail_pwd'))tmp4,
(select
wmsys.wm_concat (value) as accept_email_address
from
t_sys_setup
where
data_type in ('addressee'))tmp5,
(select
wmsys.wm_concat (value) as publicity_is_send
from
t_sys_setup
where
data_type in ('issendmail'))tmp6