2014-02-28 40 views
0

我有一个场景,我需要根据文本字段的部分获取唯一字段。我们来看看这个例子。基于文本SQL查询的部分获取唯一字段

select payload from system_metrics where category like "%action_controller%" ; 

我将得到的数据作为

payload                                                                                                   | 
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 
| --- 
:path:/
:method: GET 
:params: 
    controller: home 
    action: index 
:db_runtime: 0.507614 
:view_runtime: 24.756144 
:end_point: HomeController#index 
                                                                  | 
| --- 
:path: /api/tags?access_token=313fcd2b3ea05ff4807f848a921d5105 
:method: GET 
:params: 
    access_token: 313fcd2b3ea05ff4807f848a921d5105 
    format: json 
    action: index 
    controller: api/v1/tags 
:db_runtime: 1.5405440000000001 
:view_runtime: 1.4430399999999999 
:end_point: Api::V1::TagsController#index 
                            | 
| --- 
:path: /api/skills?access_token=313fcd2b3ea05ff4807f848a921d5105&page_no=1&page_size=10 
:method: GET 
:params: 
    access_token: 313fcd2b3ea05ff4807f848a921d5105 
    page_no: '1' 
    page_size: '10' 
    format: json 
    action: index 
    controller: api/v1/skills 
:db_runtime: 1.328608 
:view_runtime: 1.7736150000000004 
:end_point: Api::V1::SkillsController#index 
               | 
| --- 
:path: /api/tags?access_token=313fcd2b3ea05ff4807f848a921d5105 
:method: GET 
:params: 
    access_token: 313fcd2b3ea05ff4807f848a921d5105 
    format: json 
    action: index 
    controller: api/v1/tags 
:db_runtime: 3.4335250000000004 
:view_runtime: 1.536743 
:end_point: Api::V1::TagsController#index 
                              | 
| --- 
:path: /api/users/notifications 
:method: GET 
:params: 
    format: json 
    action: notifications 
    controller: api/v1/users 
:db_runtime: 1.1296910000000002 
:view_runtime: 3.0749649999999997 
:end_point: Api::V1::UsersController#notifications 
                                           | 
| --- 
:path: /api/tags?access_token=313fcd2b3ea05ff4807f848a921d5105 
:method: GET 
:params: 
    access_token: 313fcd2b3ea05ff4807f848a921d5105 
    format: json 
    action: index 
    controller: api/v1/tags 
:db_runtime: 0.6034980000000001 
:view_runtime: 1.88346 
:end_point: Api::V1::TagsController#index 
                               | 
| --- 
:path: /api/roles 
:method: GET 
:params: 
    format: json 
    action: index 
    controller: api/v1/roles 
:db_runtime: 1.005604 
:view_runtime: 40.49389600000001 
:end_point: Api::V1::RolesController#index 
                                                      | 
| --- 
:path: /api/entities?auth_token=313fcd2b3ea05ff4807f848a921d5105 
:method: GET 
:params: 
    auth_token: 313fcd2b3ea05ff4807f848a921d5105 
    format: json 
    action: index 
    controller: api/v1/entities 
:db_runtime: 4.905517 
:view_runtime: 0.400314 
:end_point: Api::V1::EntitiesController#index 

有效载荷是有这样

:path:/
:method: GET 
:params: 
    controller: home 
    action: index 
:db_runtime: 0.507614 
:view_runtime: 24.756144 
:end_point: HomeController#index 

我需要得到独特palyload每一个文本里面会有“end_point:“作为独特的像

的HomeController#指数是再次,所以我不应该重复的NXT时间...

什么是一个查询?????????????????????

+0

此表中是否有任何Id列(主列)? –

+0

yahhh我们有场名“id” –

+0

你需要什么?根据我的理解,您只需要:end_point:HomeController#index从以下位置开始:end_point –

回答

0

我不认为它是可能的。由于数据似乎是一种结构化的方式。如果数据是类似的类型或保持适当的结构,那么我们可以做到这一点。我们不能从列数据中提取任意的子字符串。阅读更多关于sub-string

+0

我只需要使用任意字符串,因为它可能动态地改变静态数据,这意味着它很容易提取数据和比较。那就是问题所在。 –