September 17, 2009 at 11:26 am
Hello - I'm really hoping someone can help me out with this.
I have this FREETEXTABLE Query (below) that works perfectly... BUT I want results/records to return ONLY if they belong to the top 10 newest records. That is, I don't want to use top_n_rank for this because I do not want the top 10 'most relevant' results, but rather I want to know if the searchstring (@searchstring) returns anything from the 10 NEWEST/LATEST records added to the database..
ANY IDEAS? PLEEEASE help!!
QUERY:
SELECT Documents.DocID,
Documents.Category,
Documents.Publication,
Documents.Volume,
Documents.Edition,
Documents.ItemTitle,
Documents.Author,
Documents.Engraver,
Documents.Keywords,
Documents.Summary,
Documents.AttachmentName,
Documents.AttachmentType,
Documents.ImageName,
Documents.ImageMedium,
Documents.ImageSize,
Documents.XMLFileName,
Documents.HTMLFileName,
KEY_TBL.RANK
FROM Documents AS Documents INNER JOIN
FREETEXTTABLE(Documents, *,
@searchstring) AS KEY_TBL
ON Documents.DocID = KEY_TBL. WHERE ((@Category IS NULL) OR (Documents.Category = @Category)) order by KEY_TBL.RANK desc
PS: Simply using 'Select TOP(10)..." doesn't work at all... 🙁
September 17, 2009 at 9:45 pm
SET ROWCOUNT 10
SELECT * FROM MYTABLE
September 18, 2009 at 5:16 pm
soo...
would I just replace the '*' in SELECT * FROM mytable with the fulltextable query??
September 18, 2009 at 9:05 pm
Apply this option with reference of the BOL.
September 20, 2009 at 2:19 pm
Hm. Thanks for the suggestion, but that solution just stops the query after N rows have been processed. That means the query will run and find any 10 rows that are most relevant according to the FREETEXTTABLE query... and then stop. This isn't what I'm looking for. I need the top 10 records to be selected first (ie the last ten records to be added to the database) and then have the FREETEXTTABLE query run on only those 10 records..
September 21, 2009 at 12:54 am
What about using a subquery. I have'nt given the full query and this is just a guess...
SELECT SELECT Documents.DocID,
Documents.Category,
Documents.Publication,
Documents.Volume,
Documents.Edition,
Documents.ItemTitle,
Documents.Author,
Documents.Engraver,
Documents.Keywords,
Documents.Summary,
Documents.AttachmentName,
Documents.AttachmentType,
Documents.ImageName,
Documents.ImageMedium,
Documents.ImageSize,
Documents.XMLFileName,
Documents.HTMLFileName,
KEY_TBL.RANK FROM
(SELECT Top 10 SELECT Documents.DocID,
Documents.Category,
Documents.Publication,
Documents.Volume,
Documents.Edition,
Documents.ItemTitle,
Documents.Author,
Documents.Engraver,
Documents.Keywords,
Documents.Summary,
Documents.AttachmentName,
Documents.AttachmentType,
Documents.ImageName,
Documents.ImageMedium,
Documents.ImageSize,
Documents.XMLFileName,
Documents.HTMLFileName,
KEY_TBL.RANK from Documents) D INNER JOIN FREETEXTTABLE......
"Keep Trying"
September 21, 2009 at 12:39 pm
May want to creat a temp table and load the top ten records into that and then run your second query aginst the contents of the temp table.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply