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
 sql 'like' when field contains space

Author  Topic 

learning_grsql
Posting Yak Master

230 Posts

Posted - 2011-10-05 : 11:57:30
hi,

I have a column like heading 'car' values "maruti suzuki", "maruti sx4", 'toyoto xx' etc. etc.
Now when I try to write query "select * from table where car like 'maruti%" it results blank. is it because the value contains space? If yes, how I can correct it. Please help

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-05 : 12:12:37
query looks fine. it should bring records with maruti suzuki, maruti sx4

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Alaveh
Starting Member

24 Posts

Posted - 2011-10-05 : 18:42:42
use this

select * from table where car like '%maruti%'
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-06 : 00:53:58
please keep in mind that last suggestion will even bring records with other words before maruthi in car field. so provided pattern maruthi is present it will get returned.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -