inner join 中 like 的查询怎么表达?

itakeblue 2009-08-01 12:07:06
INNER JOIN topic ON topic.sort_id LIKE '%sort_sort.id%'

这样写不对,因为 '%sort_sort.id%' 中的 sort_sort.id 变成了字符串

INNER JOIN topic ON topic.sort_id LIKE '%"& sort_sort.id &"%'
而一般的这样写也不对,因为 sort_sort.id 没有赋予其变量名。。。。

应该怎么写呢????
...全文
636 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
dewarfing 2011-12-29
  • 打赏
  • 举报
回复
好贴,我正在找个这个,谢谢
wssubend 2010-06-20
  • 打赏
  • 举报
回复
很不错,学习.
sasbsd 2010-03-18
  • 打赏
  • 举报
回复
看看吧
itakeblue 2009-08-01
  • 打赏
  • 举报
回复
我按照5楼的答案成了,不加ltrim就出错,换成trim也出错,呵呵

感谢各位帮助我的朋友,结贴
feixianxxx 2009-08-01
  • 打赏
  • 举报
回复
LZ人呢。。
htl258_Tony 2009-08-01
  • 打赏
  • 举报
回复
INNER JOIN topic ON LTRIM(topic.sort_id) LIKE '%'+ltrim(sort_sort.id)+'%' 
如果5楼的不行,试试这样.
feixianxxx 2009-08-01
  • 打赏
  • 举报
回复
from topic join sort_sort
on rtrim(topic.sort_id) LIKE '%sort_sort.id%'
htl258_Tony 2009-08-01
  • 打赏
  • 举报
回复
INNER JOIN topic ON topic.sort_id LIKE '%'+ltrim(sort_sort.id)+'%' 
feixianxxx 2009-08-01
  • 打赏
  • 举报
回复
直接 
from topic,sort_sort
where rtrim(topic.sort_id) LIKE '%sort_sort.id%'
itakeblue 2009-08-01
  • 打赏
  • 举报
回复
那我现在只能用 like 来查询应该怎么弄呢?? instr 可以吗?
feixianxxx 2009-08-01
  • 打赏
  • 举报
回复
[Quote=引用楼主 itakeblue 的回复:]
INNER JOIN topic ON topic.sort_id LIKE '%sort_sort.id%'

这样写不对,因为 '%sort_sort.id%' 中的 sort_sort.id 变成了字符串

INNER JOIN topic ON topic.sort_id LIKE '%"& sort_sort.id &"%'
而一般的这样写也不对,因为 sort_sort.id 没有赋予其变量名。。。。

应该怎么写呢????
[/Quote]
楼主 你把代码写写完整。。。
jiangshun 2009-08-01
  • 打赏
  • 举报
回复
on 后面要跟=的
on topic.sort_id = sort_sort.id 

34,590

社区成员

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

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