MySQL Forums
Forum List  »  Newbie

Re: Select into
Posted by: Phillip Ward
Date: November 16, 2017 11:18AM

You could use an "insert .. select ..." statement to create rows in table 'B' or use an "update" statement to change existing rows in table 'B'.

However, the question you should ask is this: are column 'X' or 'Y' [ever] likely to change?

If the answer is "Yes", then you should consider calculating this [derivable] value as and when you need it, rather than pre-calculating and storing it. This is exactly the same principle as holding DateOfBirth and calculating Age dynamically.

select x || ' Yr' || case y when 1 then ' ' else 's ' end  
   || y || ' Month' || case y when 1 then ' ' else 's ' end 
   as result
from tablea ;

Regards, Phill W.

Options: ReplyQuote


Subject
Written By
Posted
November 16, 2017 09:21AM
November 16, 2017 09:52AM
Re: Select into
November 16, 2017 11:18AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.