数据库更新查询

时间:2016-01-27 09:26:29

标签: mysql

这是我之前做的查询和

的查询
    select  E.Id as StaffId,
            SUM(IC.AmountReceived) as totalAmount,INV.InvoiceType as AccountType
            from invoice_collection IC,employee E ,invoice INV
            where IC.CollectedBy=E.id and IC.OperatorCode=#operatorCode#
            and INV.InvoiceNo=IC.InvoiceNo and E.Id=#staffId# and IC.journalFetchStatus=1
            and TxnDate > #CreatedOn#
            group by INV.InvoiceType;

我正在尝试解决具有相同条件的另一个更新问题

update invoice_collection set journalFetchStatus=0
        where IC.CollectedBy=E.id and IC.OperatorCode=#operatorCode#
        and INV.InvoiceNo=IC.InvoiceNo and E.Id=#staffId#
        and TxnDate > #CreatedOn#
        group by INV.InvoiceType;

1 个答案:

答案 0 :(得分:0)

试试这个:

update invoice_collection IC
 inner join Employee E on IC.CollectedBy=E.id
 inner join invoice INV on INV.InvoiceNo=IC.InvoiceNo
 set journalFetchStatus=0
 where IC.OperatorCode=#operatorCode#
and E.Id=#staffId#
and TxnDate > #CreatedOn#;
相关问题