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
 how to check morethan one words using like operato

Author  Topic 

kalaivani
Starting Member

11 Posts

Posted - 2007-12-18 : 02:00:06
Retrieve details of all the titles whose name contains the word computer and the word cooking (words can be present in any order. Example, Computer xyz cooking or Cooking pqrs computer)

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2007-12-18 : 02:04:57
[code]

Select * From YourTable Where (ColumnName Like '%Computer%' Or ColumnName Like '%Cooking%')
[/code]

Chirag

http://www.chirikworld.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2007-12-18 : 02:38:38
quote:
Originally posted by chiragkhabaria



Select * From YourTable Where (ColumnName Like '%Computer%' Or ColumnName Like '%Cooking%')


Chirag

http://www.chirikworld.com




I think it should have been and Chirag


Select * From YourTable Where (ColumnName Like '%Computer%' Or ColumnName Like '%Cooking%')
this retrieves results with either of two present

While

Select * From YourTable Where (ColumnName Like '%Computer%' AND ColumnName Like '%Cooking%')
ensures we have both Computer and Cooking in text which is what is required i think
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-18 : 03:02:50
quote:
Originally posted by kalaivani

Retrieve details of all the titles whose name contains the word computer and the word cooking (words can be present in any order. Example, Computer xyz cooking or Cooking pqrs computer)


If you are new to SQL. learn it
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-18 : 03:31:47
Or try the FULLTEXT serarch engine?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -