Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Other Technologies / Full-Text Search / February 2007

Tip: Looking for answers? Try searching our database.

another Freetexttable query problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
geek-y-guy - 20 Feb 2007 16:25 GMT
Hi All: Last month, I was looking for way to query 3 FT tables
simultaneously.

I found that a UNION with 3 separate queries worked, but someone pointed out
that duplicates would occur (and they did).

It was suggested that I use a query like:

select <columns>
 from table1
         inner join freetexttable(table1,*, @srchstring) ft1
                       on ft1.key = table1.<key column>
         inner join table2
                        on table2.<common key> = table1.<common key>
                        inner join freetexttable(table2,*, @srchstring) ft2
                                      on ft2.key = table2.<key column>

I did get that to work, but the problem is the query won't return any
matches if the searchstring is not found in both FT tables.

Going back to my original goal, I have 3 tables:

products
manufacturers
skus

And these tables are all in the FT cat.

I want to be able to search for a term like "blue" or "5180-1" (a sku) and
return a match from any table in the FT cat.

Is there any way to do it with the nested join query above? Or is there
another way to do it?

Before I started using the freetexttable query, I was using some fugly code
like:

   SELECT <columns> FROM products WHERE <columns> LIKE '%<searchstr>%'
   <if no results then>
   SELECT <columns> FROM manufacturers WHERE <columns> LIKE '%<searchstr>%'

...do I need to do something like that, but instead concatenate the results
from each query into a temp table?

Thanks for any advice!

--
Simon Sabin - 20 Feb 2007 23:57 GMT
Hello geek-y-guy,

If you use a left join your query should work

Simon Sabin
SQL Server MVP
http://sqlblogcasts.com/blogs/simons

> Hi All: Last month, I was looking for way to query 3 FT tables
> simultaneously.
[quoted text clipped - 42 lines]
>
> Thanks for any advice!
geek-y-guy - 21 Feb 2007 00:37 GMT
Thanks Simon, but are you saying a left join for every join in the query?
for the 3 tables there would be 6 joins in total.

> Hello geek-y-guy,
>
[quoted text clipped - 50 lines]
>>
>> Thanks for any advice!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.