好的,我正在尝试在SQL Server 2008上执行此操作:
select *
from tb_contato
inner join tb_url_contato on tb_contato.RIGHT(linkurl, CHARINDEX('/', REVERSE(linkurl)) - 1) = tb_url_contato.url
这不起作用。有关最佳方法的任何建议吗?
感谢。
答案 0 :(得分:1)
RIGHT
是sql中的内置函数。我认为linkurl
是表tb_contato
中的一列。
SELECT *
FROM tb_contato
INNER JOIN tb_url_contato
ON RIGHT(tb_contato.linkurl, CHARINDEX('/', REVERSE(tb_contato.linkurl))-1) = tb_url_contato.url
答案 1 :(得分:1)
只需使用right()
,即可在没有like
的情况下执行此操作。我认为逻辑是:
SELECT *
FROM tb_contato INNER JOIN
tb_url_contato
ON tb_contato.linkurl LIKE '%/' + tb_url_contato.url
答案 2 :(得分:0)
试试这个
SELECT * FROM (SELECT * ,RIGHT(linkurl, COALESCE(NULLIF(CHARINDEX('/', REVERSE(linkurl)), 0) - 1, LEN(linkurl))) AS NEWCOL FROM tb_contato ) AS TA inner join tb_url_contato TB on TA.NEWCOL = TB.url