搜索用逗号分隔值的列 [英] Searching a column with comma separated values

查看:115
本文介绍了搜索用逗号分隔值的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有SQL Server 2008 R2的版本,这很努力和网​​页作为前端。

来到了该问题,是基本上由用逗号分隔的各种技能的数据库中的列。例如,某些候选人有3种不同的技能,即设置 C# SQL服务器的Oracle 。谁希望列出同时具有的技能候选人的用户 C#甲骨文将提供输入作为在网页上的文本框C#,甲骨文。我想编写一个查询,可以列出这样的。我曾尝试自由文本搜索。但它未能提取若资本/小词,为通配符的支持,技能甚至秩序。

下面是示例查询

  SELECT * FROM型材,其中自由文本(技能,'C#,甲骨文)


解决方案

从我的POV正确的(和不受欢迎的)答案是重新设计你的表结构:你永远也不会有值的列表中的一个字段,如果你要分别访问它们。

I have SQL server 2008 r2 edition, which am working on and a .Net webpage as front end.

Coming to the issue, there is a column in the database which basically consists of various skill sets separated by a comma. For example some candidate has a 3 different skill sets namely C#, SQL server, Oracle. The user who wants to list the candidates having the skills of both C# and Oracle will provide the input as C#, Oracle in a text box on the webpage. I want to write a query which can list out such. I have tried freetext search. But it fails to fetch if in Capital/small words, no support for wildcard character, even the order of skills.

Below is the sample query

Select * from profiles where freetext(skills, ‘C#,Oracle’)

解决方案

From my POV the correct (and unwelcome) answer is to redesign your table structure: You should never ever have a list of values in a single field, IF YOU WANT TO ACCESS THEM SEPARATELY.

这篇关于搜索用逗号分隔值的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆