日期:2014-05-18  浏览次数:21081 次

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)+'%'