SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Sep 2009
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SQL server full text indexing, ranking and joining to other tables

    i searched the net about sql server full text indexing and ranking and got this sample sql statement and it works using 1 table only:

    SELECT myTable1.id, myTable1.Title, fulltextSearch.Rank
    FROM myTable1
    JOIN
    FreeTextTable(myTable1, [myField1], 'awesome ranking') fulltextSearch
    ON
    myTable1.id = fulltextSearch.[KEY]
    ORDER BY Rank DESC

    what i do not know is how to make it to work when it is joined to another table. how do i do that if i have these sample tables?

    myTable1
    ----------
    id myField1
    1 rrrrrrr
    2 qqqqqqq
    3 kkkkkkk
    .
    .
    .
    .

    myTable2
    -------

    id myTable1Foreign
    1 4
    3 6
    2 1
    .
    .
    .

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,400
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    How do you want to join it? What do you want to do with the second table?

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,015
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    try this --
    Code:
    SELECT myTable1.id
         , myTable1.Title
         , fulltextSearch.Rank
         , myTable2.somecolumn
      FROM myTable1
    INNER
      JOIN FreeTextTable(myTable1,[myField1],'awesome ranking') 
           AS fulltextSearch
        ON fulltextSearch.[KEY] = myTable1.id
    INNER
      JOIN myTable2
        ON myTable2.myTable1Foreign = myTable1.id
    ORDER 
        BY fulltextSearch.Rank DESC
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Member
    Join Date
    Sep 2009
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks very much R937. it worked!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •