List:General Discussion« Previous MessageNext Message »
From:Chris W Date:March 17 2010 8:20pm
Subject:Re: SQL command for MySQL ?
View as plain text  
I'm not 100% sure I understand what you are wanting but if I do, the 
INSERT ... ON DUPLICATE KEY UPDATE Syntax detailed here....

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)
(1, 1, 4, '2010-03-16 06:00:00', '2010-03-16 06:59:59')

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
SQL command for MySQL ?Stephane MAGAND17 Mar
  • Re: SQL command for MySQL ?Chris W17 Mar