SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Search with string including space.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

hspatil31
Posting Yak Master

182 Posts

Posted - 03/04/2013 :  08:53:43  Show Profile  Reply with Quote
Dear All,

I am trying following query for search the record by string name.
When I searching with single word like 'build' I am getting records.
But when I am searching with like 'build computer', I am not getting any records.
Can anyone please help me how to search including space in string ?

Query:

SELECT * FROM PRODUCT WHERE NAME LIKE '%build%'

Thanks,
Harish Patil

Thanks and Regard's
Harish Patil

James K
Flowing Fount of Yak Knowledge

3585 Posts

Posted - 03/04/2013 :  08:56:32  Show Profile  Reply with Quote
May be one of the following? Each is implementing a different logic.
SELECT * FROM PRODUCT WHERE NAME LIKE '%build computer%'
SELECT * FROM PRODUCT WHERE NAME LIKE '%build%computer%'
SELECT * FROM product WHERE NAME LIKE '%build%' AND NAME LIKE '%computer%'
SELECT * FROM product WHERE NAME LIKE '%build%' OR NAME LIKE '%computer%'
Go to Top of Page

hspatil31
Posting Yak Master

182 Posts

Posted - 03/04/2013 :  09:32:37  Show Profile  Reply with Quote
Hello John,

Actually I want to search whose name contains the build also and computer also.
Means it should consider the separate word.
Can you please tell me how to do this ?



Thanks and Regard's
Harish Patil
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3585 Posts

Posted - 03/04/2013 :  09:58:23  Show Profile  Reply with Quote
Actually I am the third one in the gallery here, not the fourth. But, that aside, the third query I posted would work for what you described:
SELECT * FROM product WHERE NAME LIKE '%build%' AND NAME LIKE '%computer%'
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000