如果把字符串的子串作为查询条件?

Lansie 2007-06-26 10:35:57
为了表述方便,简化了下问题
两张表
表名 字段 字段 字段
[article1] id1, title1,content1
[article2] id2, title2,content2

想要在article1找出所有id2为12,25的title1为titile2的子串的记录,怎么找啊
上面的话好像有点拗口
意思就是先找出select * from article1 where id=12 or id=25
然后在article1中找出上面记录集中title1为其子串的记录

谢了!
...全文
189 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
fwacky 2007-06-26
  • 打赏
  • 举报
回复
you dian cuo
fwacky 2007-06-26
  • 打赏
  • 举报
回复
select * from article1 A
where exists
(select 1 from article1 B where B.id=12 or B.id=25 and A.id = B.id)
Zack999 2007-06-26
  • 打赏
  • 举报
回复
select a.* from article1 a,article2 b where (a.id=12 or a.id=25) and charindex(a.title1,b.title2)>0
ivan_ren 2007-06-26
  • 打赏
  • 举报
回复
不明白楼主的意思

34,837

社区成员

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

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