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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

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



Feb 3, 2001, 2:57 AM

Post #1 of 2 (248 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


Feb 5, 2001, 1:44 AM

Post #2 of 2 (241 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.

  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.

  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