我在简化此查询时遇到问题。
我需要将 12 设为变量,因此我只需设置一次,并且%BrightSide08
.
因为我需要用不同的名称和长度重复这个。
Declare @len int, @name varchar
SET @len = 12
SET @name = '%BrightSide08'
UPDATE CHAR_DATA0
SET CHAR_DATA = (SELECT CHAR_DATA FROM xtreme.dbo.CHAR_DATA0
WHERE CONVERT(VARCHAR(12), SUBSTRING(CHAR_DATA, 9, 16)) LIKE '%BrightSide08')
WHERE CHAR_KEY = (
SELECT top (1) CHAR_KEY
FROM CHAR_DATA0
WHERE USER_KEY = (SELECT USER_KEY FROM xtreme.dbo.CHAR_DATA0
WHERE CONVERT(VARCHAR(12), SUBSTRING(CHAR_DATA, 9, 16)) LIKE '%BrightSide08')
)
UPDATE CHAR_INFOR
SET CHARID0 = (SELECT CONVERT(VARCHAR(12), SUBSTRING(CHAR_DATA, 9, 16)) FROM xtreme.dbo.CHAR_DATA0
WHERE CONVERT(VARCHAR(12), SUBSTRING(CHAR_DATA, 9, 16)) LIKE '%BrightSide08')
WHERE USER_KEY = (
SELECT top (1) USER_KEY
FROM CHAR_DATA0
WHERE USER_KEY = (SELECT USER_KEY FROM xtreme.dbo.CHAR_DATA0
WHERE CONVERT(VARCHAR(12), SUBSTRING(CHAR_DATA, 9, 16)) LIKE '%BrightSide08')
)
SELECT *
FROM CHAR_DATA0
WHERE USER_KEY = (SELECT USER_KEY FROM xtreme.dbo.CHAR_DATA0
WHERE CONVERT(VARCHAR(12), SUBSTRING(CHAR_DATA, 9, 16)) LIKE '%BrightSide08')
SELECT *
FROM [game].[dbo].[CHAR_INFOR]
WHERE USER_KEY = (
SELECT top (1) USER_KEY
FROM game.dbo.CHAR_DATA0
WHERE USER_KEY = (SELECT USER_KEY FROM xtreme.dbo.CHAR_DATA0
WHERE CONVERT(VARCHAR(12), SUBSTRING(CHAR_DATA, 9, 16)) LIKE '%BrightSide08')
)
我错过了什么吗?请纠正我。谢谢你。