我有以下表格:
TARIF_COURANT
CODE_TARIF NO_CLIENT ZONE UNITE
A_0_300 8585 1 8
A_0_300 8585 1 5
T_TARIF_ZONE
NO_ID LIBELLE
1 A
2 B
T_UNITE
NO_ID LIBELLE
8 MOT
5 FUT
我怎样才能让Update
我的表TARIF_COURANT
得到这个结果:
CODE_TARIF NO_CLIENT ZONE UNITE
A-MOT_0_300 8585 1 8
A-FUT_0_300 8585 1 5
我试过这样:
UPDATE
TARIF_COURANT
SET
TARIF_COURANT.CODE_TARIF = T_TARIF_ZONE.LIBELLE +'-'
+ RTRIM(LTRIM( T_UNITE.LIBELLE) )+'_'
+CONVERT(varchar, [TR_DEB])
+'_'+CONVERT(varchar, [TR_FIN])
FROM
TARIF_COURANT
left join T_UNITE on TARIF_COURANT.unite = T_UNITE.NO_ID
left join T_TARIF_ZONE on TARIF_COURANT.zone = T_TARIF_ZONE.NO_ID
where no_client = '850673' and unite != 1
ON
TARIF_COURANT.CODE_TARIF = TARIF_COURANT.CODE_TARIF