Set ANSI_NULLS ON <br/> set QUOTED_IDENTIFIER ON <br/> go <br/> alter function [dbo]. [fun_Str] (@ SourceSql varchar (8000), @ StrSeprate varchar (10) <br/> RETURNS @ temp TABLE (a varchar (100 )) <br/> BEGIN <br/> DECLARE @ I int <br/> SET @ SourceSql = RTRIM (@ SourceSql )) <br/> SET @ I = charindex (@ StrSeprate, @ SourceSql) <br/> WHILE @ I> = 1 <br/> BEGIN <br/> INSERT @ temp values (left (@ SourceSql, @ i-1 )) </p> <p> SET @ SourceSql = SUBSTRING (@ SourceSql, @ I + 1, LEN (@ SourceSql)-@ I) </p> <p> SET @ I = CHARINDEX (@ StrSeprate, @ SourceSql) <br/> END <br/> IF @ SourceSql <> '/' <br/> INSERT @ temp values (@ SourceSql) <br/> RETURN <br/> END <br/>
The above is the SQL method,
Select B. *,. weburl from UsedCar_SubSiteList a, UsedCar_FriendLink B <br/> where. id in (<br/> SELECT a FROM dbo. fun_Str (. subSiteIds <br/>, ',') <br/>)
Table Structure Relationship
SubSiteList (id, weburl)
FriendLink (id, name, subIds)
Description: The format of the subIds saved field is: 1, 2, 3, 4, 5...; subIds Save the id value in SubSiteList;