以下の現在のデータを以下の目的のデータのように見せるSQL更新ステートメントを作成しようとしています。
親 ID が 0 の場合、ErrorDescriptionWithParent はその行の errorDescrtiption になります。
親 ID が 0 でない場合、errordescriptionwithparent は、区切り文字で区切られた親のエラーの説明と子のエラーの説明を連結した値になります。
図については、以下のデータを参照してください。合体機能を使用しようとしましたが、適切な文字列を作成できません。前もって感謝します
現在のサンプル データ
ID ErrorDescription ErrorDescriptionWithParent ParentID
1 XYZ 0
2 Operator 1
希望するサンプルデータ
ID ErrorDescription ErrorDescriptionWithParent ParentID
1 XYZ XYZ 0
2 Operator XYZ-Operator 1
以下は、ParentID が 0 のレコードの更新ステートメントです。ParentID が 0 でない場合に ErrorDescriptionWithParent を更新するための更新ステートメントの作成に助けが必要です。
UPDATE errorcode
set ErrorDescriptionWithParent = ErrorDescription
where parentID = 0