Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Complex Search Problem

Author  Topic 

sp_wiz
Yak Posting Veteran

55 Posts

Posted - 2001-11-10 : 19:31:38
Well it is to me.....

I have two tables

CREATE TABLE [dbo].[PHOTOS] (
[BASE_TRANS_NO] [nchar] (15)

Of course there are more fields than shown above

Table 2

CREATE TABLE [dbo].[KEYWORD] (
[ID] [int] NOT NULL ,
[TRANS_NO] [nchar] (15) ,
[WORD] [nchar] (40)
)

The link between the tables is the base_trans_no from phots an trans_no from Keyword.

As you can see the relationship between the tables allows multiple keywords to belong to one photo..

The problem I'm having is writing a sql statement that will look for multiple keywords. ie I want to pass a string into an sp like 'Rose Red' I have no problem getting the logic to pull back all records that contain rose or red, but i can not see away to pull back only those records that contain ROSE ANE RED.

Heres part of the SP

SELECT photos.trans_no , PicDesc, PHM_Name,rtrim(THNail_Path)
FROM dbo.PHOTOS WHERE Photos.base_trans_no in ( Select keyword.trans_no from keyword where " + @keywords +" )"
EXEC(@CMD)

{call dbo.Opus_QuickSearch(1,10,'Not Selected','(((RTRIM(Word) LIKE ''%GARDEN%'') AND(RTRIM(Word) LIKE ''%Rose%'')))')}

I have some ASP code that generates the where part of the clause, I would also like to be able to say NOT instead of AND

Any ideas would be great as the deadline is for Monday

Robp


   

- Advertisement -