mysql存储过程是否支持数组,哈希等数据类型?

时间:2010-04-22 06:08:04

标签: mysql stored-procedures

我正在创建一个mysql函数,该函数接收varchar并根据映射表将其更改为int。

select name, convert_to_code(country) from users where sex = 'male'

这里,convert_to_code()函数接受国家/地区名称(例如日本,芬兰..),并根据名为{的映射表将其更改为国家/地区代码,即整数(例如1001,2310 ..) {1}}如下所示:

country_maping

目前,存储的函数需要country_name (varchar) | country_code (int) Japan | 1001 Finland | 2310 Canada | 8756 并返回查询结果。是可以在SP中创建一个哈希数据结构来优化流程,这样就不需要对每一行执行查询就匹配select country_code from country_mapping where country_name = country_name子句。

提前感谢!

1 个答案:

答案 0 :(得分:0)

你应该像你一样使用这张桌子。

如果在这两列上创建覆盖索引,则应使其尽可能高效。