From: Chris W Date: March 17 2010 8:20pm Subject: Re: SQL command for MySQL ? List-Archive: http://lists.mysql.com/mysql/220989 Message-Id: <4BA139A2.2040401@cox.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit I'm not 100% sure I understand what you are wanting but if I do, the INSERT ... ON DUPLICATE KEY UPDATE Syntax detailed here.... http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html Will probably do what you want. For it to work you would have to have a unique key on the three fields (dom_id, Date_Start and Date_End). So your query would look like this INSERT INTO Table_Logs_Summary (mails_recus ,mail_rbl, dom_id, Date_Start, Date_End) VALUES (1, 1, 4, '2010-03-16 06:00:00', '2010-03-16 06:59:59') ON DUPLICATE KEY UPDATE mails_recus=(mails_recus+1),mail_rbl=(mail_rbl+1) Chris W Stephane MAGAND wrote: > Hi > > i am debutant in SQL and i am search to know if it's possible: > > > My SQL requets: > > > UPDATE Table_Logs_Summary SET > mails_recus=(mails_recus+1),mail_rbl=(mail_rbl+1) WHERE dom_id=4 AND > Date_Start="2010-03-16 06:00:00" AND Date_End="2010-03-16 06:59:59"; > > > I wan't know if they have a optimised sql requets for said if the > WHERE don't exist, he create it ! > (if he don't have dom_id=4 AND Date_Start="2010-03-16 06:00:00" AND > Date_End="2010-03-16 06:59:59" he > create by in INSERT) (a IF NO EXIST ?) > > > thanks > Stephane > >