2015-05-11 74 views
-1
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%' 
+0

['SELECT']嘗試(https://msdn.microsoft.com/en-us/library/ms189499.aspx) - 請向下滾動到「邏輯處理訂單因爲SELECT子句是第8步,所以在子句中定義的任何列別名或派生列都不能被前面的子句引用......「 - 'WHERE'是第4步。 –

回答

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

Yees it works.thanks! :) – Axmed