TechTalkz.com Logo

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Microsoft > Microsoft SQL Server

Notices

Reply
 
LinkBack Thread Tools Display Modes
Old 27-11-2007, 02:32 AM   #1
wdudek
Guest
 
Posts: n/a
full text search on multiple columns

My scenario is as follows. I have an application that allows users to search
on multiple columns for one or more values. i.e. account_number, account_name
and order_number can be searched on. Using contains and or containstable, I
have not been able to get this to work as expected. The query seems to be
only returning results for rows that have the value in all of the columns, is
there any way to make it return if any onr of the columns matches? My current
strategy has been to concatenate all the values into one column when the data
is loaded/updated and have the index on this column. While this does work, it
seems like I shouldn't have to do this?

Thanks

Bill
  Reply With Quote
Old 27-11-2007, 02:30 PM   #2
Charles Wang[MSFT]
Guest
 
Posts: n/a
RE: full text search on multiple columns

Hi Bill,
I understand that you would like to return the rows that have the value in
any of the columns.
If I have misunderstood, please let me know.

To narrow down this issue, could you please let us know what your T-SQL
statement was? Did you try OR statement? For example:
SELECT *
FROM tblText
WHERE CONTAINS(account_number, @searchword)
OR CONTAINS(account_name, @searchword)
OR CONTAINS(order_number, @searchword)

Please feel free to let me know if you have any other questions or
concerns. Have a nice day!


Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====


  Reply With Quote
Old 27-11-2007, 04:30 PM   #3
ML
Guest
 
Posts: n/a
RE: full text search on multiple columns

Please, post the query. Are all of those columns full-text indexed?


ML

---
Matija Lah, SQL Server MVP
http://milambda.blogspot.com/
  Reply With Quote
Old 27-11-2007, 08:31 PM   #4
wdudek
Guest
 
Posts: n/a
RE: full text search on multiple columns

I was hoping that I wouldn't need to use an OR statement, but I think you
answered my question. Essentially I wanted to use the predicate contains(*,
'*ABC* OR *08117*') where the asterik for the column list would indicate
several columns, some that may have the valeus and some that would not in one
or more records. If an OR statement and multiple contains statements is the
only way to do this, I will continue to concatenate the data into a seperate
field, which is ok as this database is only used for performing searches.

Thanks,

"Charles Wang[MSFT]" wrote:

> Hi Bill,
> I understand that you would like to return the rows that have the value in
> any of the columns.
> If I have misunderstood, please let me know.
>
> To narrow down this issue, could you please let us know what your T-SQL
> statement was? Did you try OR statement? For example:
> SELECT *
> FROM tblText
> WHERE CONTAINS(account_number, @searchword)
> OR CONTAINS(account_name, @searchword)
> OR CONTAINS(order_number, @searchword)
>
> Please feel free to let me know if you have any other questions or
> concerns. Have a nice day!
>
>
> Best regards,
> Charles Wang
> Microsoft Online Community Support
> ================================================== ===
> When responding to posts, please "Reply to Group" via
> your newsreader so that others may learn and benefit
> from this issue.
> ================================================== ====
> This posting is provided "AS IS" with no warranties, and confers no rights.
> ================================================== ====
>
>
>

  Reply With Quote
Old 27-11-2007, 08:32 PM   #5
ML
Guest
 
Posts: n/a
RE: full text search on multiple columns

Actually, CONTAINS also accepts a column list.

E.g.:
SELECT *
FROM tblText
WHERE CONTAINS
(
(account_number, account_name, order_number)
,@searchword
)


ML

---
Matija Lah, SQL Server MVP
http://milambda.blogspot.com/
  Reply With Quote
Old 29-11-2007, 04:29 PM   #6
Charles Wang[MSFT]
Guest
 
Posts: n/a
RE: full text search on multiple columns

Yes, this is simpler. First recommend it.

Hi Bill,
Just check with you to see if you need further assistance on this issue.
Please feel free to let us know if you have any questions or concerns. Have
a nice day!

Best regards,
Charles Wang
Microsoft Online Community Support

================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====

  Reply With Quote
Reply

Thread Tools
Display Modes


Google
 


All times are GMT +5.5. The time now is 05:31 PM.


vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2008, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional