"Andrei V.Loukinykh" wrote:
> If anybody know how to handle the problem, let me know please.
> I have 2 tables with the similar 4 fields.
> The first table is temporary( and small) and the second one is big.
> table TMP table MAIN
> DATE DN ConvTime DIGITS DATE DN ConvTime DIGITS
> I want to add each record from the TMP into the MAIN in condition, that
> there is no record in MAIN with the same combination of DATE,DN and
> DIGITS. Otherwise ( if such a combination already exists) I have to
> replace existing record with the new one BUT THE FIELD ConvTime MUST BE
> That's all.
> Thanks in advance.
If you have an UNIQUE KEY over Date, DN and DIGITS you can use the REPLACE syntax
,IFNULL(main.ConvTime,tmp.ConvTime,tmp.ConvTime + main.ConvTime)
LEFT JOIN main