OK... updating if a record exists or creating a record if there are zero records is a pretty simple matter and you have a solution for it. That having been said, I would do something different and keep track of my message of the day by date:
-- This is REALLY BASIC, but, just to give you the idea...
CREATE TABLE [dbo].[MessageOfTheDay](
[MessageDate] [date] not null,
[MessageContents] [nvarchar](500) not null,
UNIQUE (MessageDate)
)
declare @MessageContents nvarchar(500), @MessageDate date
set @MessageContents = 'This is the new MOTD!!!'
set @MessageDate = GETDATE()
-- Every day, create a new record and you can keep track of previous MOTD entries...
insert into MessageOfTheDay(MessageDate, MessageContents)
values (@MessageDate, @MessageContents)
-- Get the message for today
select MessageContents from MessageOfTheDay where MessageDate = @MessageDate
-- If you want, you can now create messages for FUTURE days as well:
set @MessageContents = 'This is tomorrow''s MOTD!!!';
set @MessageDate = dateadd(D, 1,GETDATE())
insert into MessageOfTheDay(MessageDate, MessageContents)
values (@MessageDate, @MessageContents)
-- Get tomorrow's message
select MessageContents from MessageOfTheDay where MessageDate = @MessageDate
-- If you aren't necessarily going to have one per day and want to always just show the most recent entry
select MessageContents from MessageOfTheDay order by MessageDate desc limit 1
Anyway, that's just my $.02. At some point I bet you will want to look over the history of your MOTD and when you do, you will be happy that you have that history. Plus, this more accurately models the data you are trying to represent.
WHERElineINSERT ... ON DUPLICATE KEY UPDATEdev.mysql.com/doc/refman/5.6/en/insert-on-duplicate.html