Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
wafw1971
Yak Posting Veteran
75 Posts |
Posted - 2013-05-07 : 05:07:13
|
I want to be able to search for different words like Red or Blue or Fry and bring back a distinct list using a WHERE clause, I have written my query below but it doesn't seem to be bringing anything back can you tell what I have done wrong?DECLARE @Test VARCHAR (200)SET @Test = @TestSELECT H.Name, O.Name AS Owner, S.SilksName, T.Name AS Trainer, J.FirstName + ' ' + J.LastName AS JockeyFROM Horse AS H LEFT OUTER JOIN Owner AS O ON CHARINDEX(@Test, O.Name) <> 0 LEFT OUTER JOIN Trainer AS T ON CHARINDEX(@Test, T.Name) <> 0 LEFT OUTER JOIN Silks AS S ON CHARINDEX(@Test, S.SilksName) <> 0 LEFT OUTER JOIN Jockey AS J ON CHARINDEX(@Test, J.FirstName) <> 0 OR CHARINDEX(@Test, J.LastName) <> 0WHERE @Test LIKE 'Red' |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
wafw1971
Yak Posting Veteran
75 Posts |
Posted - 2013-05-07 : 10:40:58
|
All sorted now thanks. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-08 : 00:27:03
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|