Re: Query for search engine

From: Michael C (me_at_mine.com)
Date: 01/21/05


Date: Fri, 21 Jan 2005 15:09:09 -0500

Try this:

SELECT i1.iPageID
FROM iTable i1
INNER JOIN iTable i2
ON i1.iPageID = i2.iPageID
WHERE i1.sPhrase LIKE '%searchword1%'
AND i2.sPhrase LIKE '%searchword2%'

Keep in mind that LIKE '%xxx%' is going to be a performance-killer,
especially twice in one query, since it won't be able to effectively take
advantage of indexes - on any system as far as I know.

Thanks
Michael C#, MCDBA

"Ray" <Ray@discussions.microsoft.com> wrote in message
news:5D31C6FA-6105-4711-A23F-0E8ABC493698@microsoft.com...
> Sample data:
> iParseID iPageID sPhrase
iRank
> 22592 daacf052-122a-446b-99c4-ead865dd468f home 33
> 22593 2cb2ebf2-4268-498a-9128-d223f09253e7 page 43
> 22594 2cb2ebf2-4268-498a-9128-d223f09253e7 home 15
> 22595 588e6a38-5f0e-4704-87f5-e5d17f6033f0 trade 24
> 22596 e51b431c-4b29-4316-8f45-0ac24b8fc812 home 23
> 22597 daacf052-122a-446b-99c4-ead865dd468f london 51
>
> When I do a search for "london home" then I only want the iPageID of
record
> 22597 returned and not for 22594 nor 22596.
>
> Both records 22594 and 22596 has "home" as a value for sParse, but there
are
> no other records where the iPageID is the same as for records 22594 and
22596
> and has "london" as the value for sPhrase.
>
> I hope this makes sence.
>
> I am trying to create a solution where the database can be ported to any
> relational database and is not restricted to SQL server. We use Access on
> our internet site and SQL for our intranet sites. It is therefore
> impractical to develop purely using Full Text Indexing.
>
> Thanks
> Ray
>
>
> "Alejandro Mesa" wrote:
>
> > I think the logical operator AND in the where clause is doing it. If
not,
> > Could you please post some DDL, sample data and expected result?
> >
> >
> >
> > AMB
> >
> >
> >
> > "Ray" wrote:
> >
> > > I have created an indexing service that populates a details table with
the
> > > stripped out phrases from the web pages.
> > >
> > > The details table has a few fields including:
> > > iParseID int (primary key)
> > > iPageID string
> > > sPhrase string
> > > iRank int
> > >
> > > The iPageID field contains a GUID value that forms the relationship
with the
> > > master table.
> > >
> > > sPhrase contains the keywords/phrases that were stripped out of the
web page.
> > >
> > > I need to select the iPageID where sPhrase contains the search words.
I
> > > know the syntax will be something like:
> > >
> > > SELECT iPageID FROM tbParse WHERE sPhrase LIKE '%searchword1%' and
sPhrase
> > > LIKE '%searchword2%' ORDER BY iRank
> > >
> > > The question is how can I only get the records where searchword1 and
> > > searchword2 are on? I don't want iPageID returned if only one of the
values
> > > are present.
> > >



Relevant Pages

  • Re: Query for search engine
    ... add the following line to the end of the previous query: ... > relational database and is not restricted to SQL server. ... > our internet site and SQL for our intranet sites. ...
    (microsoft.public.sqlserver.programming)
  • Re: ORDER BY in VIEW not working
    ... As an object-oriented programmer, I expect to be able to encapsulate ... But a relational database is not in Kansas, ... has statistics, and the statistics are unique to the table, because the ... Again, while you don't care about performance, most users of SQL Server do, ...
    (comp.databases.ms-sqlserver)
  • Access SUMs Full Column When Using Subquery
    ... I jumped over to SQL Server, and it gave me the results I wanted, so ... Sample Data: Students_02272005_1 ... SELECT clause due to conditions specified on the subquery's WHERE ... Stud_ID Lesson PercentAbove5 ...
    (microsoft.public.access.queries)
  • Re: join on 3 tables for asp output
    ... The table structure and sample data is ... >> Mondays since I am scheduling instruments for a whole week. ... > some outer joins (I'm assuming this is SQL Server, ... > quicker response by posting to the newsgroup. ...
    (microsoft.public.inetserver.asp.db)
  • Re: how to conver nvarchar with value like(12.23) to time (12:23)
    ... Can you please give us a script of some sample data to try out? ... Pro SQL Server 2000 Database Design - ... > "Arithmetic overflow error converting expression to data type datetime" ... > INSERT INTO TourItemsTemp (FromTime, ToTime, TimeCodeID, ...
    (microsoft.public.sqlserver.programming)