Searching for a string in a field

Results 1 to 2 of 2

Thread: Searching for a string in a field

  1. #1
    StuckGirl Guest

    Default Searching for a string in a field

    Hi,<BR><BR>I want to search for a string in a text field. If it is found I want to have that record part of the record set. I am in Access 2000 passing the parameter to the database. I have tried a bunch of combinations with no success... I know I can do this easily with the asp code, but I want the database to do it...this is what I have so far...<BR><BR>SELECT [tblMyTable].[Article]<BR>FROM tblArticles<BR>WHERE InStr(1, Article,[whatword?],1)&#062;0;<BR><BR>what word being passed from the asp which I know how to do. Just basically trying to make the query in Access. I searched the faq and this message board but didn&#039;t seem to find an answer...but I know it must be here cause it seems like an easy/common question....but I can&#039;t seem to find it.<BR><BR>THanks for any advice...<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Searching for a string in a field

    SELECT [tblMyTable].[Article]<BR>FROM tblArticles<BR>WHERE InStr(1, Article,[whatword?],1)&#062;0;<BR><BR>Well, you can&#039;t do that because you are asking for the field Article from one table but specifying only a different table in the FROM clause. <BR><BR>The generic way:<BR><BR>SELECT * FROM tablename WHERE fieldname LIKE &#039;%someword(s)%&#039;<BR><BR>Or, in ASP code:<BR><BR>SQL = "SELECT * FROM tablename WHERE fieldname LIKE &#039;%" & Request("words") & "%&#039;"<BR><BR><BR>

Posting Permissions

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