首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

inner join 中 like 的查询如何表达

2012-02-20 
inner join 中 like 的查询怎么表达?INNER JOIN topic ON topic.sort_id LIKE %sort_sort.id%这样写不对

inner join 中 like 的查询怎么表达?
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 没有赋予其变量名。。。。

应该怎么写呢????

[解决办法]
on 后面要跟=的

SQL code
on topic.sort_id = sort_sort.id
[解决办法]
探讨
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 没有赋予其变量名。。。。

应该怎么写呢????

[解决办法]
SQL code
INNER JOIN topic ON topic.sort_id LIKE '%'+ltrim(sort_sort.id)+'%' 

热点排行