我希望能够在“where”子句中输入一个单词,它会在所有表中搜索该单词或类似的单词,这可以做到吗
DECLARE @Test VARCHAR (200)
SET @Test = 'Red'
SELECT H.Name, O.Name AS 'Owner', S.SilksName, T.Name AS 'Trainer'
FROM Horse H
INNER JOIN Owner O on CHARINDEX(@Test,O.Name) <> 0 or
INNER JOIN Trainer T ON CHARINDEX(@Test,T.Name) <> 0 or
INNER JOIN Runners R ON Horse.Horse_Skey = Runners.Horse_Skey
INNER JOIN Silks S ON CHARINDEX(@Test,S.SilksName) <> 0 or
INNER JOIN Jockey J ON CHARINDEX(@Test,J.FirstName) <> 0
WHERE @Test = 'Red'