结果:

用于解决  这种 字段的查询

1.先创建分割函数 => 复制到数据库直接执行

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
by kudychen 2011-9-28
*/
CREATE function [dbo].[SplitNum]
(
@Input nvarchar(max), --input string to be separated
@Separator nvarchar(max)=',', --a string that delimit the substrings in the input string
@RemoveEmptyEntries bit=1 --the return value does not include array elements that contain an empty string
)
returns @TABLE table
(
[Id] int identity(1,1),
[Value] nvarchar(max)
)
as
begin
declare @Index int, @Entry nvarchar(max)
set @Index = charindex(@Separator,@Input)

while (@Index>0)
begin
set @Entry=ltrim(rtrim(substring(@Input, 1, @Index-1)))

if (@RemoveEmptyEntries=0) or (@RemoveEmptyEntries=1 and @Entry<>'')
begin
insert into @TABLE([Value]) Values(@Entry)
end

set @Input = substring(@Input, @Index+datalength(@Separator)/2, len(@Input))
set @Index = charindex(@Separator, @Input)
end

set @Entry=ltrim(rtrim(@Input))
if (@RemoveEmptyEntries=0) or (@RemoveEmptyEntries=1 and @Entry<>'')
begin
insert into @TABLE([Value]) Values(@Entry)
end

return
end

2.查询   =>自己替换表

SplitNum=>函数,

Value=> 要查询的值

----------------------------------

select * from 表 where id
in
(
select distinct ad.adid from (select a.id adid,recrid.Id,recrid.Value from 表 a outer apply SplitNum(a.expirationdate,',',2) recrid ) ad where ad.Value=15
)

最新文章

  1. Bzoj3524 [Poi2014]Couriers
  2. PHP mkdir()无写权限的问题解决方法
  3. Effective C++ -----条款05:了解C++默默编写并调用哪些函数
  4. Java编程思想学习(十二) 数组和容器
  5. JVM总结
  6. apache 配置order allow deny讲解
  7. Atitit.Gui控件and面板----web server区----- web服务器监控面板and控制台条目
  8. Linux与JVM的内存关系分析(转)
  9. 【HighCharts系列教程】六、去除highCharts版权信息的几种方法
  10. VB.NET中的常用方法
  11. Ubuntu16.04 install OpenJDK8
  12. js switch 字符串
  13. nginx配置打印请求响应内容
  14. css美化滚动条
  15. 程序中使用now()函数对性能的影响
  16. 有关g++的Xlinker选项
  17. tf.contrib.rnn.static_rnn与tf.nn.dynamic_rnn区别
  18. 对于“机器视觉(computer version)”的反思
  19. [DeeplearningAI笔记]序列模型2.10词嵌入除偏
  20. shell kill session

热门文章

  1. C#DataTableRow列值互转
  2. 【学习日志】MongoDB为什么选择B树,而MySQL选择B+树实现索引
  3. spring in action day07 RabbitMq
  4. Sentinel入门到实操 (限流熔断降级)
  5. 4.12 疫情数据可视化 毕设(初稿版 crud+可视化echarts
  6. 毕设进度更新(真的不知道自己做到哪- - 备忘录性质)+3.19是mavan配置的常见问题
  7. 学习Java Day30
  8. 如何使用 ArrayPool
  9. Java7.10
  10. 鼎阳SDS6204示波器的EPICS IOC调试