In MSSQL you can create a table with a computed column, like this...
CREATE FUNCTION CubicVolume
-- Input dimensions in centimeters.
( [at] CubeLength decimal(4,1), [at] CubeWidth decimal(4,1),
[at] CubeHeight decimal(4,1) )
RETURNS decimal(12,3) -- Cubic Centimeters.
AS
BEGIN
RETURN ( [at] CubeLength * [at] CubeWidth * [at] CubeHeight )
END
CREATE TABLE Bricks
(
BrickPartNmbr int PRIMARY KEY,
BrickColor nchar(20),
BrickHeight decimal(4,1),
BrickLength decimal(4,1),
BrickWidth decimal(4,1),
BrickVolume AS
(
dbo.CubicVolume(BrickHeight,
BrickLength, BrickWidth)
)
)
Is there an equivalent in MySQL beside views, stored procedures or
calculating it in a query?
I'm not trying to implement it; I'm just curious.
