I've written a MySQL function that calculates a price:
CREATE DEFINER=`[USER]`@`[HOST]` FUNCTION `calculatePrice`(id INT)
RETURNS DECIMAL(8,2) DETERMINISTIC
BEGIN
IF id=10 THEN
RETURN 899;
ELSE
RETURN 710;
END IF;
END
This works how it should, but next to the price, I want to add a string containing the reason of the price.
That function should be used like this:
SELECT id, calculatePrice(id).price AS price, calculatePrice(id).reason AS reason FROM person;
Is this possible with MySQL and how does it work?
Thanks!