我怎么能在哪里写new_column?

时间:2015-05-11 13:21:23

标签: sql sql-server sql-server-2008 select

SELECT  *,STUFF((SELECT ',' + struktur_bolmesi
FROM tb_Structure WHERE  concat(',',bolmeler,',')  LIKE concat('%,',struktur_id,',%')
FOR XML PATH('') ), 1, 1, '') as new_column from tb_Customers where new_column like '%text%'

1 个答案:

答案 0 :(得分:0)

请尝试使用此

 WITH Tbl AS(
            SELECT  *,STUFF((SELECT ',' + struktur_bolmesi
    FROM tb_Structure WHERE  concat(',',bolmeler,',')  LIKE concat('%,',struktur_id,',%')
    FOR XML PATH('') ), 1, 1, '') 
            as new_column from tb_Customers
    )
    SELECT  *
    FROM    Tbl
    WHERE   new_column LIKE '%text%'