0
私のストアドプロシージャをSql Server
からMySql
に移行しています。temporaryayテーブルの更新mysql
どこか私は一時的な変数のMS SQLサーバーから更新クエリを変換する問題に直面しています。私はyoureのがやろうとしたが、あなたのクエリは、さまざまな理由のために完全に間違っているのかわからないのです
update sampleStoreTV set felony = c.fel,misdemeanor = c.mis,violation = c.vio
from (select srcCL.id as 'storeId',
case when SUM(case when srcCL.cl='FELONY' then 1 else 0 end)>0 then 1 else 0 end as 'fel',
case when SUM(case when srcCL.cl='MISDEMEANOR' then 1 else 0 end)>0 then 1 else 0 end as 'mis',
case when SUM(case when srcCL.cl='VIOLATION' then 1 else 0 end)>0 then 1 else 0 end as 'vio'
from
(select DM_Sample_Store.DM_Sample_Store_ID as 'id',
Charge_Level.Mapped_Charge_Level as 'cl'
from DM_Sample_Store
left join screening_result on Screening_Result.Screening_Result_id = DM_Sample_Store.Screening_Result_id
left join Crim_Case on Screening_Result.Screening_Result_id = Crim_Case.Screening_Result_id
left join Crim_Charge on Crim_Case.Crim_case_id = Crim_Charge.Crim_case_id
left join PDL_DataSource on DM_Sample_Store.DataSource_Id = PDL_DataSource.DataSource_Id
left join DM_Sample_Search_Param on DM_Sample_Store.DM_Sample_Store_ID = DM_Sample_Search_Param.DM_Sample_Store_ID
left join Charge_Level on Crim_Charge.Sanitized_Charge_Level_id = Charge_Level.Charge_Level_id
where PDL_DataSource.DataSource_Id = dataSourceId
and DM_Sample_Store.Active = 1
and DM_Sample_Search_Param.Global_Search_Parameter_ID in (sosGspId, freqGspId, clGspId, dtGspId)
and DM_Sample_Search_Param.Active = 1
-- and Crim_Charge.AOR_Days is not null
) srcCL
group by id
having SUM(case when cl='FELONY' then 1 else 0 end)>0
or SUM(case when cl='MISDEMEANOR' then 1 else 0 end)>0
or SUM(case when cl='VIOLATION' then 1 else 0 end)>0) c
where sampleId = c.storeId
感謝トンを支援を期待
::私はそれがそのようなものかもしれないと思う)それが働きました –