I'm trying to execute this query:
        UPDATE  
            arc_salon_credit_exposant AS asce
        SET  
            asce.asce_credit_restant = 
                (
                    SELECT 
                        SUM(asce_credit_restant) 
                    FROM
                        arc_salon_credit_exposant
                    WHERE
                        asce_scre_id = '524' AND
                        asce_sexp_id = '719' AND
                        (asce_fam_id is NULL OR
                            asce_fam_id = '168')
                )
        WHERE  
            asce.asce_scre_id = '524' AND
            asce.asce_sexp_id = '719' AND
            asce.asce_fam_id is NULL
but, all I get is a mysql error (#1093 - You can't specify target table 'asce' for update in FROM clause). I've read some questions here at stackoverflow (that's why I tried using an alias), but I can't make it work. I know I have to write the query so Mysql will create a temp table, but.. I can't get this done. Kinda stuck here.
Here's the structure of the table:
Column name Type    Null    Défaut
asce_id int(11) Non 
asce_scre_id    int(11) Non 
asce_sexp_id    int(11) Non 
asce_credit_restant double  Oui NULL
asce_fam_id int(11) Oui NULL
And here's some data:
asce_id asce_scre_id asce_sexp_id asce_credit_restant asce_fam_id
35 524 7885 4900 NULL
17 524 719 200 NULL
45 524 719 100 168
44 524 7885 100 168
Thanks in advance
 
     
    