473,378 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to display records according to this rule?

Hello,

I have a search form in an ASP.NET/VB page.
The form has the input text box and the button "search".

The keywords are passed in the URL to results.aspx.

Here is an example:
results.aspx?search=asp%20book%20london

(%20 means for space)

I used the words "asp", "book", "london".

Each database record has 2 fields: "title" and "description".

I want to display all the records where at least one of the keywords is
found in any of the 2 fields "title" and "description".

1. I suppose I need to get the words out of the URL to be used by SQL.
Am I right? How can I do this?

2. How should the SQL look?

I have been applying filters but never something as complex as this
search.

Thanks,
Miguel

Nov 19 '05 #1
5 1280
Hi,

If you enable Full-Text Search on the database and also the table in
question you can use the following query and pass directly the search
string:

SELECT < some columns or * > FROM < your table >
INNER JOIN
FREETEXTTABLE(< your table >, < column or * >, @p_freetext) AS KEY_TBL
ON < your table >.< your table's unique key> = KEY_TBL.[KEY]
(optionally:)
WHERE ....
(recommended:)
ORDER BY KEY_TBL.[RANK]

Then just add the @p_freetext parameter to the parameters of the command.

See the topics related to full-text querying in MS SQL Server Books Online
for more details and examples.

Hope this helps
Martin Dechev
ASP.NET MVP
"Miguel Dias Moura" <md*REMOVE*moura@*NOSPAM*gmail.com> wrote in message
news:eb**************@TK2MSFTNGP11.phx.gbl...
Hello,

I have a search form in an ASP.NET/VB page.
The form has the input text box and the button "search".

The keywords are passed in the URL to results.aspx.

Here is an example:
results.aspx?search=asp%20book%20london

(%20 means for space)

I used the words "asp", "book", "london".

Each database record has 2 fields: "title" and "description".

I want to display all the records where at least one of the keywords is
found in any of the 2 fields "title" and "description".

1. I suppose I need to get the words out of the URL to be used by SQL.
Am I right? How can I do this?

2. How should the SQL look?

I have been applying filters but never something as complex as this
search.

Thanks,
Miguel

Nov 19 '05 #2
This isn't really complex at all.
1. I suppose I need to get the words out of the URL to be used by SQL.
Am I right? How can I do this?
string[] aryValues = Request.QueryString("search").Split(' ');
2. How should the SQL look?
SELECT * FROM mytable WHERE title LIKE '%asp%'
OR title LIKE '%book%'
OR title LIKE '%London%'
OR description LIKE '%asp%'
OR description LIKE '%book%'
OR description LIKE '%London%'

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Miguel Dias Moura" <md*REMOVE*moura@*NOSPAM*gmail.com> wrote in message
news:eb**************@TK2MSFTNGP11.phx.gbl... Hello,

I have a search form in an ASP.NET/VB page.
The form has the input text box and the button "search".

The keywords are passed in the URL to results.aspx.

Here is an example:
results.aspx?search=asp%20book%20london

(%20 means for space)

I used the words "asp", "book", "london".

Each database record has 2 fields: "title" and "description".

I want to display all the records where at least one of the keywords is
found in any of the 2 fields "title" and "description".

1. I suppose I need to get the words out of the URL to be used by SQL.
Am I right? How can I do this?

2. How should the SQL look?

I have been applying filters but never something as complex as this
search.

Thanks,
Miguel

Nov 19 '05 #3
Hi,

I am a little bit about your solution.
Sorry but I am new in this.

How to I apply " string[] aryValues =
Request.QueryString("search").Split(' ');" to be executed when the page
loads?

The number of Keywords it's not always 3. It can be more.
I suppose your SQL doesn't predicts that.

Thanks,
Miguel

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:ks******@takempis.com:
This isn't really complex at all.
1. I suppose I need to get the words out of the URL to be used by SQL.
Am I right? How can I do this?


string[] aryValues = Request.QueryString("search").Split(' ');
2. How should the SQL look?


SELECT * FROM mytable WHERE title LIKE '%asp%'
OR title LIKE '%book%'
OR title LIKE '%London%'
OR description LIKE '%asp%'
OR description LIKE '%book%'
OR description LIKE '%London%'

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Miguel Dias Moura" <md*REMOVE*moura@*NOSPAM*gmail.com> wrote in message
news:eb**************@TK2MSFTNGP11.phx.gbl...
Hello,

I have a search form in an ASP.NET/VB page.
The form has the input text box and the button "search".

The keywords are passed in the URL to results.aspx.

Here is an example:
results.aspx?search=asp%20book%20london

(%20 means for space)

I used the words "asp", "book", "london".

Each database record has 2 fields: "title" and "description".

I want to display all the records where at least one of the keywords
is
found in any of the 2 fields "title" and "description".

1. I suppose I need to get the words out of the URL to be used by SQL.
Am I right? How can I do this?

2. How should the SQL look?

I have been applying filters but never something as complex as this
search.

Thanks,
Miguel


Nov 19 '05 #4
Hi,

It seems good but I got lost. :-)

Where can I find MS SQL Server Books Online?

Is there any disadvantage of enabling a database to Full-Text Search?

Thanks,
Miguel

"Martin Dechev" <de*******@hotmail.com> wrote in message
news:de*******@hotmail.com:
Hi,

If you enable Full-Text Search on the database and also the table in
question you can use the following query and pass directly the search
string:

SELECT < some columns or * > FROM < your table >
INNER JOIN
FREETEXTTABLE(< your table >, < column or * >, @p_freetext) AS KEY_TBL
ON < your table >.< your table's unique key> = KEY_TBL.[KEY]
(optionally:)
WHERE ....
(recommended:)
ORDER BY KEY_TBL.[RANK]

Then just add the @p_freetext parameter to the parameters of the
command.

See the topics related to full-text querying in MS SQL Server Books
Online
for more details and examples.

Hope this helps
Martin Dechev
ASP.NET MVP
"Miguel Dias Moura" <md*REMOVE*moura@*NOSPAM*gmail.com> wrote in message
news:eb**************@TK2MSFTNGP11.phx.gbl...
Hello,

I have a search form in an ASP.NET/VB page.
The form has the input text box and the button "search".

The keywords are passed in the URL to results.aspx.

Here is an example:
results.aspx?search=asp%20book%20london

(%20 means for space)

I used the words "asp", "book", "london".

Each database record has 2 fields: "title" and "description".

I want to display all the records where at least one of the keywords
is
found in any of the 2 fields "title" and "description".

1. I suppose I need to get the words out of the URL to be used by SQL.
Am I right? How can I do this?

2. How should the SQL look?

I have been applying filters but never something as complex as this
search.

Thanks,
Miguel


Nov 19 '05 #5
Hi,

"Miguel Dias Moura" <md*REMOVE*moura@*NOSPAM*gmail.com> wrote in message
news:e1**************@TK2MSFTNGP09.phx.gbl...
Hi,

It seems good but I got lost. :-)

Where can I find MS SQL Server Books Online?
If have chosen to install them (they are optional components in the SQL
Server installation) - Start -> Programs -> Microsoft SQL Server -> Books
Online.

Is there any disadvantage of enabling a database to Full-Text Search?
The SQL Server process takes some more memory (and some CPU time when
creating and updating the index). For small databases - there is small
difference. Also, for small databases Kevin's solution is ok - it will be
reasonably fast.

Greetings
Martin Dechev
ASP.NET MVP

Thanks,
Miguel

"Martin Dechev" <de*******@hotmail.com> wrote in message
news:de*******@hotmail.com:
Hi,

If you enable Full-Text Search on the database and also the table in
question you can use the following query and pass directly the search
string:

SELECT < some columns or * > FROM < your table >
INNER JOIN
FREETEXTTABLE(< your table >, < column or * >, @p_freetext) AS KEY_TBL
ON < your table >.< your table's unique key> = KEY_TBL.[KEY]
(optionally:)
WHERE ....
(recommended:)
ORDER BY KEY_TBL.[RANK]

Then just add the @p_freetext parameter to the parameters of the
command.

See the topics related to full-text querying in MS SQL Server Books
Online
for more details and examples.

Hope this helps
Martin Dechev
ASP.NET MVP
"Miguel Dias Moura" <md*REMOVE*moura@*NOSPAM*gmail.com> wrote in message
news:eb**************@TK2MSFTNGP11.phx.gbl...
Hello,

I have a search form in an ASP.NET/VB page.
The form has the input text box and the button "search".

The keywords are passed in the URL to results.aspx.

Here is an example:
results.aspx?search=asp%20book%20london

(%20 means for space)

I used the words "asp", "book", "london".

Each database record has 2 fields: "title" and "description".

I want to display all the records where at least one of the keywords
is
found in any of the 2 fields "title" and "description".

1. I suppose I need to get the words out of the URL to be used by SQL.
Am I right? How can I do this?

2. How should the SQL look?

I have been applying filters but never something as complex as this
search.

Thanks,
Miguel

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jack | last post by:
Hi, I need to build a asp page where it would serve as a data entry record page as well as display page for records saved. This page should also allow editing of records that has been saved. ...
4
by: Darrel | last post by:
I'm creating a table that contains multiple records pulled out of the database. I'm building the table myself and passing it to the page since the table needs to be fairly customized (ie, a...
13
by: Ennio-Sr | last post by:
Hi all! After a very long struggle I finally succeded in transferring my old *.dbf file and the relating *.dbt (alias memo fields) to a pg table. For the time being I put the memo field in a...
4
by: drew197 | last post by:
I am a newbie. I am editing someone elses code to make it compatible with Firefox and Safari. In IE, when you click on the proper link, a block of text is shown in a nice paragraph form. But, in...
1
by: Arpan | last post by:
The following code displays records from a SQL Server 7 database table in a DataList (when the page loads for the first time, all the records under the column named "FName" in the DB table are...
6
by: Ken Fine | last post by:
I'm using SQLDataSource, which generates some kind of dataset, and then I attach that datasource to various data display controls such as DataList and repeater which loop through to the end of the...
0
by: Amit | last post by:
Hi All, Can any one write me the Code to sort datagridviewcomboboxcolumn according to display member property. By default is it sorted according to value member but I want to sort according to...
4
by: seth_hickel | last post by:
With other solutions I would get a recordset, read each record and display data by formating my html as I wanted to display values of each record. I am trying to display data in a three column...
7
by: imtmub | last post by:
I have 3 table for Purchase Order from ERP Database Tables: POD=Purchase order Details(this table has Require Qty field) POR=Purchase Order Receive (This table has RequireQty and ReceiptQty...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.