查询语句出现问题

twfx7758 2009-02-23 05:55:11

select b_id, b_title from bidding where flag>0 and datediff(dd, update_flag_time, getdate())=0 and it_id + ',' like '%0,%' order by b_id DESC

it_id + ',' like '%0,%'我只想查出符合0,条件的数据,结果10,的也查出来啦,请问如何解决啊?请高手帮忙
...全文
115 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
twfx7758 2009-02-24
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 happyflystone 的回复:]
it_id + ',' like '0,%'

it_id + ',' like '%[^1]0,%'
[/Quote]
用正则的方法行不通中,啥也查不出来!
twfx7758 2009-02-24
  • 打赏
  • 举报
回复
咋没有兄弟回答了啊?
twfx7758 2009-02-23
  • 打赏
  • 举报
回复
还有朋友知道怎么实现吗?晕啦,搞不明白啦,表设计的太怪!
lushanhong 2009-02-23
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 libin_ftsafe 的回复:]
it_id + ',' like '0,%' ??
[/Quote]
支持
%就代表了任意串
'%0,%'匹配含"0,"的任意串
twfx7758 2009-02-23
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 happyflystone 的回复:]
it_id + ',' like '0,%'

it_id + ',' like '%[^1]0,%'
[/Quote]
如果用这个,后面查询10,的数据咋办呢?
twfx7758 2009-02-23
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 josy 的回复:]
引用 2 楼 josy 的回复:
SQL codeselect b_id, b_title
from bidding
where flag>0
and datediff(dd, update_flag_time, getdate())=0
and ','it_id + ',' like '%,0,%'
order by b_id DESC


?



SQL codeselect b_id, b_title
from bidding
where flag>0
and datediff(dd, update_flag_time, getdate())=0
and ','+it_id + ',' like '%,0,%'
order by b_id DESC
[/Quote]

谢谢你的回答,要是我那个前面没有,呢,只有后面有呢??
-狙击手- 2009-02-23
  • 打赏
  • 举报
回复
it_id + ',' like '0,%'

it_id + ',' like '%[^1]0,%'
twfx7758 2009-02-23
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 libin_ftsafe 的回复:]
it_id + ',' like '0,%' ??
[/Quote]

it_id是一个键值,就是后面的0,
其实是:"it_id + ',' like '%" + num.ToString().
数据库里面的格式是:0,2,3等等,反正就是0到15的排序! 查0,的时候10,的数据也出现啦,请问如何解决,谢谢!
百年树人 2009-02-23
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 josy 的回复:]
SQL codeselect b_id, b_title
from bidding
where flag>0
and datediff(dd, update_flag_time, getdate())=0
and ','it_id + ',' like '%,0,%'
order by b_id DESC


?
[/Quote]

select b_id, b_title 
from bidding
where flag>0
and datediff(dd, update_flag_time, getdate())=0
and ','+it_id + ',' like '%,0,%'
order by b_id DESC
百年树人 2009-02-23
  • 打赏
  • 举报
回复
select b_id, b_title 
from bidding
where flag>0
and datediff(dd, update_flag_time, getdate())=0
and ','it_id + ',' like '%,0,%'
order by b_id DESC

?
子陌红尘 2009-02-23
  • 打赏
  • 举报
回复
it_id + ',' like '0,%' ??

34,873

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧