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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query Help

Author  Topic 

Jamaral141989
Starting Member

6 Posts

Posted - 2013-10-09 : 11:29:56
I'm looking for a query that searches the table for keywords but I also need it to search for two-three keywords within that phrase but those words don't have to be paired for results. I'm currently using a simple one...
SELECT Role, Permission

FROM [Permissiontable].[dbo].[Master Table]

WHERE Permission LIKE '%test%'

but the problem with this is that if i were to search "test search" it would only bring up results that have exactly "test search" paid together but won't bring up something like "test is the search" even thou both of those keywords are inthe phrase. Hope this makes sense.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-10-09 : 13:05:06
do you mean this?

SELECT Role, Permission

FROM [Permissiontable].[dbo].[Master Table]

WHERE Permission LIKE '%test%search%'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-10-09 : 14:02:18
[code]SELECT Role ,
Permission
FROM [Permissiontable].[dbo].[Master Table]
WHERE Permission LIKE '%test%'
AND Permission LIKE '%search%'[/code]
Go to Top of Page

Jamaral141989
Starting Member

6 Posts

Posted - 2013-10-09 : 14:24:48
SELECT Role ,
Permission
FROM [Permissiontable].[dbo].[Master Table]
WHERE Permission LIKE '%test%'
AND Permission LIKE '%search%'

works, I was having a brain fart moment. Thanks.
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-10-09 : 15:14:29
You are very welcome - glad to help.
Go to Top of Page
   

- Advertisement -