By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,829 Members | 673 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,829 IT Pros & Developers. It's quick & easy.

SQL - Keyword searching / partial match

P: 2
Firstly i would like to know the difference between Keyword searching using SQL and partial matching of a search.

I have to search for a book by key word in the book title. But allow TWO key words in the Query.

This is what i have:

Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM Books
  3. WHERE Title LIKE '*Nature*' OR Title LIKE '*Britain*';
This is searching for the book "The Nature of Britain.

However i feel this is wrong somehow and i should b doing it another way. Please Help.
Thanks
Jan 10 '08 #1
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 634
Firstly i would like to know the difference between Keyword searching using SQL and partial matching of a search.

I have to search for a book by key word in the book title. But allow TWO key words in the Query.

This is what i have:

Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM Books
  3. WHERE Title LIKE '*Nature*' OR Title LIKE '*Britain*';
This is searching for the book "The Nature of Britain.

However i feel this is wrong somehow and i should b doing it another way. Please Help.
Thanks
Hi
If you want to return all recorords with both nature AND britain (in that order) in the tiltle then pehaps this:
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM Books
  3. WHERE Title LIKE '*Nature*Britain*';
If you want to return all recorords with both nature AND britain (but in any order) in the tiltle then pehaps this:
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM Books
  3. WHERE Title Like '*Nature*' AND Title Like '*Britain*';
Your origional query returns all books with nature OR britain in the title.

MTB
Jan 10 '08 #2

P: 2
Thanks that helps, But is this called a 'Keyword' search, because i have another problem which is very similar.

I have to search for a book by its author.
But it states that i should allow partial matching of the Authors names.

All i have done for this is the same as above.
But there must be a difference between partial matching a search and a keyword search.

Many Thanks.
Jan 10 '08 #3

Expert 100+
P: 634
Thanks that helps, But is this called a 'Keyword' search, because i have another problem which is very similar.

I have to search for a book by its author.
But it states that i should allow partial matching of the Authors names.

All i have done for this is the same as above.
But there must be a difference between partial matching a search and a keyword search.

Many Thanks.
I think to Like operator with the asterisk does precisely what you want. Try serching in Help for 'Like Operator' for a full explanation of its capabilities.

MTB
Jan 11 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.