CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Keyword Search using DBI in MS SQL Server

 



chandrika
Deleted

Feb 3, 2001, 2:57 AM

Post #1 of 2 (170 views)
Keyword Search using DBI in MS SQL Server Can't Post

Can anybody help me for keyword search if keywords are stored in database seperated by commas like
(search, data, post) then program should be able to search for the particular site depending on any of the keywords.

This Program searches for the site which contains the first keyword if you enter the other keywords corresponding to the same site it won't work.
As i know we should use split function to separate the keywords which is separated by comma. i don't how to use it.

thanx in advance
chandrika



Kanji
User

Feb 5, 2001, 1:44 AM

Post #2 of 2 (163 views)
Re: Keyword Search using DBI in MS SQL Server [In reply to] Can't Post

You shouldn't do this in perl but in your SQL query so that you only return matching rows from your database instead of the entire table.


Code
  SELECT id 
FROM table
WHERE keyword LIKE '%perl%'

That should work, but will also match improperly, so you may want to make the keyword search a little more explicit either by using a seperate index instead of comma seperated values or by using a more bloated query.


Code
  SELECT id 
FROM table
WHERE keyword = 'perl' -- By itself ...
OR keyword LIKE 'perl,%' -- ... at the beginning ...
OR keyword LIKE '%,perl' -- ... at the end ...
OR keyword LIKE '%,perl,%' -- ... or in the middle


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives