just wondering if this is possible
say I have news_title and news_date, can I make news_title default to news_date if not entered?
this example I guess is a little more complicated because datetime has different display methods. But I’m curious to know either way.
You’d have to use a trigger if you wished to make the db do this, or you could quite simply use which ever programming language you are using to check the data entered before it was sent off to the db and alter it before creating your query.
When selecting your data, provided that the news_title field is set to null if not specified, you can use the COALESCE function, which returns the first of its parameters which is not null.
SELECT COALESCE(news_title, news_date) AS title...