鉴于以下内容。
Products_Joined.METATAG_Keywords AS Keyword,
这将为“keyword”
返回此信息shoe,sneaker,boot,slipper
我想把它分成不同的字段。
keyword1 shoe
keyword2 sneaker
keyword3 boot
keyword4 slipper
类似于逗号分隔符上的Javascript拆分功能。
不幸的是,这是该字段存储在数据库中的方式。
编辑:虽然我认为这并不重要,但我提供了完整的SQL查询,也许有人可以告诉我这是哪个版本的SQL。
SELECT
'home-and-garden-products > home decorations > rugs' AS Category,
SUBSTRING(Products_Joined.ProductName, 6,LEN(Products_Joined.ProductName)) AS [stripHTML-Title],
'Config_FullStoreURL' + 'ProductDetails.asp?ProductCode=' + Products_Joined.IsChildOfProductCode AS Link,
Products_Joined.ProductCode AS SKU,
CAST(IsNull(Products_Joined.SalePrice,Products_Joined.ProductPrice) AS VARCHAR(30)) AS Price,
Products_Joined.ProductManufacturer AS Brand,
Products_Joined.UPC_code AS UPC,
'Config_FullStoreURLConfig_ProductPhotosFolder/' + IsNull(Products_Joined.IsChildOfProductCode,Products_Joined.ProductCode) + '-2T.jpg' AS Image,
Products_Joined.ProductDescription AS [stripHTML-DESCRIPTION],
Products_Joined.ProductManufacturer AS Manufacturer,
Products_Joined.vendor_partno AS [Mfr part number],
'0' AS [Shipping Cost],
Products_Joined.Google_Color AS Color,
Products_Joined.Google_Material AS Material,
Products_Joined.ProductWeight AS [Shipping Weight],
Products_Joined.Google_Size AS Size,
Products_Joined.METATAG_Keywords AS Keyword,
Products_Joined.ProductWeight AS Weight
FROM Products_Joined WITH (NOLOCK)
WHERE (Products_Joined.ProductPrice > 0)
AND (Products_Joined.IsChildOfProductCode IS NOT NULL)
ORDER BY Products_Joined.ProductCode
答案 0 :(得分:1)
您可能会发现this page包含您正在寻找的解决方案。
希望它有所帮助!
答案 1 :(得分:1)
查看此SPLIT功能,我希望能提供您正在寻找的解决方案 - http://vadivel.blogspot.com/2011/10/how-to-split-delimited-string-values-in.html