-3
子查詢返回超過1行,在concat
操作語法錯了,我能不能識別語法錯誤錯誤拋出的子查詢返回超過1行
select case when a.log_type='Schedule'
then (select replace(concat(c.leadbank_name,'\n',time(b.schedule_time),'\n',b.schedule_type,'\n',b.schedule_remarks,'\n'),'\n','<br />')
from crm_trn_tschedulelog b
where b.log_gid=a.log_gid)
when a.log_type='Call Log'
then (select replace(concat(c.leadbank_name,'\n','Person',' @ ',c.mobile_number,' on ',
cast(DATE_FORMAT(c.call_date,'%d-%m-%Y') as char),'\n',c.remarks),'\n','<br />')
from crm_trn_tcalllog c where c.log_gid=a.log_gid) when a.log_type='Meeting'
then (select replace(concat(c.leadbank_name,'\n','Mr/Ms ', d.fieldvisit_contactperson,
' at ', d.fieldvisit_location,' on ', cast(DATE_FORMAT(d.fieldvisit_date,'%d-%m-%Y') as char),
' for ',(concat(d.fieldvisit_hour,':',fieldvisit_minute,':00')),' Hours ','\n',d.fieldvisit_remarks),'\n','<br />')
from crm_trn_tfieldlog d where d.log_gid=a.log_gid)
when a.log_type='Mail Log'
then (select cast(replace (concat(date_format(i.sent_date,'%d-%m-%Y %h:%i:%s %p'),'\n',
i.sender_emailid,'\n',i.subject,'\n'),'\n','<br />') as char) from acc_trn_temails i where i.log_gid=a.log_gid) end as log_details,
case when a.log_type='Schedule' then (select case when e.schedule_type='Call Log' then
concat(d.user_firstname,' ',d.user_lastname,' ','Scheduled a Call On',' ', date_format(e.schedule_date,'%d-%m-%Y'))
when e.schedule_type='Meeting'
then concat(d.user_firstname,' ',d.user_lastname,' ','Scheduled a Meeting On', ' ',
date_format(e.schedule_date,'%d-%m-%Y')) when e.schedule_type='Mail Log'
then concat(d.user_firstname,' ',d.user_lastname,' ','Scheduled Mail On',' '
,date_format(e.schedule_date,'%d-%m-%Y')) end from crm_trn_tschedulelog e where e.log_gid=a.log_gid)
when a.log_type='Call Log' then (select cast(concat(g.user_firstname,' ',g.user_lastname,' ','Called') as char)
from crm_trn_tcalllog f left join adm_mst_tuser g on f.called_by = g.user_gid where f.log_gid = a.log_gid)
when a.log_type='Meeting' then (select cast(concat(h.fieldvisit_contactperson2,' ','Met') as char)
from crm_trn_tfieldlog h where h.log_gid=a.log_gid)
when a.log_type='Mail Log'
then (select cast(concat('Mail Sent By ',g.user_firstname,' ',g.user_lastname) as char)
from crm_trn_tlog f left join adm_mst_tuser g on f.log_by = g.user_gid where f.log_gid = a.log_gid)
end as log_legend, a.leadbank_gid,e.leadbankcontact_gid,f.campaign_gid,f.lead2campaign_gid from crm_trn_tlog a
left join hrm_mst_temployee b on a.log_by=b.user_gid left join adm_mst_tuser d on a.log_by=d.user_gid
left join crm_trn_tleadbank c on a.leadbank_gid=c.leadbank_gid
left join crm_trn_tleadbankcontact e on c.leadbank_gid=e.leadbank_gid
LEFT JOIN CRM_TRN_TLEAD2CAMPAIGN f on a.reference_gid=f.lead2campaign_gid
where b.employee_gid in('SERM1509230001','SERM1509230005','SERM1509230004','SERM1509230006',
'SERM1510130002','SERM1510130003','SERM1510150004','SERM1510150005','SERM1509230002','1') and
a.log_date BETWEEN CURDATE()-INTERVAL 1 WEEK AND CURDATE() order by a.log_gid desc ;
請格式化您的代碼。至於你的問題,我並不感到驚訝,你不能確定問題出在哪裏。 – Paul
你的標籤是自相矛盾的:如果你使用vb.net,那麼你不使用asp-classic,反之亦然。如果這就是你的代碼,呃,在現實生活中「格式化」,然後弄清楚錯誤所在的地方會帶來一個小小的奇蹟。 – Martha
此外,如果問題是關於SQL查詢,它實際上可以識別您正在使用的SQL版本。 – Dijkgraaf