日期:2014-05-17 浏览次数:20551 次
SELECT *
FROM dbo.[zone] z LEFT OUTER JOIN
dbo.property_info pi ON LEFT(z.spare2, 1) = 'P' AND CONVERT(int,
REPLACE(z.spare2, 'P', '')) = pi.ID LEFT OUTER JOIN
community_info ci ON LEFT(z.spare2, 1) = 'C' AND CONVERT(int, REPLACE(z.spare2,
'C', '')) = ci.id LEFT OUTER JOIN
SELECT *
FROM dbo.[zone] z LEFT OUTER JOIN
dbo.property_info pi CONVERT(int,
REPLACE(z.spare2, 'P', '')) = pi.ID
where LEFT(z.spare2, 1) = 'P' union
SELECT *
FROM dbo.[zone] z LEFT OUTER JOIN
community_info ci ON LEFT(z.spare2, 1) = 'C' AND CONVERT(int, REPLACE(z.spare2, 'C', '')) = ci.id
where LEFT(z.spare2, 1) = 'C'