比较 SQL 中的三个逗号分隔值 [英] Comparing three Comma separated values in SQL

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

问题描述

比较sql中两个逗号分隔的值,我们可以使用Split类的函数来完成.(三列也可以!)但是,不使用这些功能可以吗?

Comparing two comma separated values in sql, we can get done by using Split kind of functions.(Three columns also we can do !) But, without using the functions is that possible?

让我举个例子.

查询应检查以下条件

(1) 从表 1 中选择计划中的任务.但不在完成或拒绝列中.

(1) Select the tasks from Table- 1 That is Planned. But Not in done or declined columns.

(2) 只返回强制任务

(2) Return only the mandatory tasks

使用拆分功能(UD 函数)或 Cursor 会使查询变得更加复杂,并且也会占用时间.

Using Split functionality(UD Functions) or Cursor is making query more complex and it swallows the time as well.

是否有其他解决方案来完成这项工作?可以使用单个查询吗?

Is there any alternative solution to get this done? Possible with single query ?

提前致谢.

推荐答案

不,没有灵丹妙药.如果你真的想提高性能,这可以被标准化(可能被索引).此外,更标准的查询可以在没有拆分功能的情况下工作.

No there is no magic bullet. If you really want to increase performance this could be normalized (maybe indexed). Also, more standard queries would work without a split function.

根据具体情况,它可能会有所不同,但从您展示的内容来看,我将有一个任务表,其中每一行与 table1 相关的任务似乎是包含许多任务的工作"或项目".

Depending on the exact situation it might be different but from what you show I would have a tasks table with one row for every task that related to table1 which appears to be 'jobs' or 'projects' that contain many tasks.

仅仅出现在表格中意味着它们是计划任务,其中包含强制性、拒绝和已完成的列.

Just being in the table means that they are planned tasks with columns for mandatory, declined and completed.

如果您无法对这些数据进行标准化,那么您很可能会使用拆分函数.有一些关于从 CLR 函数似乎运行得非常快的拆分函数中获得出色性能的文章.

If you can not normalize this data then you are likely stuck with split functions. There are articles about getting great performance from split functions with CLR functions appearing to run quite fast.

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

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