MySQL function to compare values in a db table against the previous
Posted
by Stuart
on Stack Overflow
See other posts from Stack Overflow
or by Stuart
Published on 2010-03-15T21:39:25Z
Indexed on
2010/03/15
22:49 UTC
Read the original article
Hit count: 215
Iam quite new to functions in SQL and I would like to create a function to compare values in a MySQL table against previous and I am not sure how to do this.
For example (iId is the input value)
DECLARE pVal INT(20); DECLARE val INT(20); SELECT price INTO pVal FROM products WHERE Id=iId; SELECT price FROM products; IF price == pVal THEN SET val = price; END IF;
Thanks
© Stack Overflow or respective owner