function
/ * Function: The function will only return a value, not allowed to return a result set. It stressed that the return value of the function, it does not allow the situation to return multiple values, even query. Separated by commas into a plurality of parameters. Note: In the function, if the same query table field with the parameter name, you need to prefix the field name with an alias, or when there are problems in identifying the program does not complain, but a problem with the query results. * / Drop function IF EXISTS Myf; Create function Myf (REGION_CODE VARCHAR ( 10 )) Returns int the begin DECLARE C int ; - definition of variables, requires the query into a variable C INTO XXX SELECT; SELECT PM10 from data_region_month T WHERE T. REGION_CODE = REGION_CODE limit . 1 INTO C; return c; end; select myf('411025'); select myf(region_code) from data_region_month;
Stored Procedures