Results 1 to 4 of 4
  1. #1
    ABW Ambassador
    Join Date
    January 18th, 2005
    Posts
    1,663
    I need to return records from an author field where the data consists of first name & second name and sometimes co-authors. My search needs to be able to find results if only the last name is entered in the search box.

    Example: Entering "King" needs to return records where the author field might be "Stephen King and Peter Straub"

    None of the usual operators in the SQL "Where" clause allows searching within the field. Anyone have a trick I've overlooked before I start messing with the database queries?

    Thanks,

    Wayne

  2. #2
    Pimp Duck popdawg's Avatar
    Join Date
    January 18th, 2005
    Location
    Take off eh?
    Posts
    3,249
    resource intensive but ...
    where <FIELDNAME> like '%<SEARCHTERM>%'

    Must Build More in 2004
    Game on!!!! - The DawgFather

  3. #3
    ABW Ambassador
    Join Date
    January 18th, 2005
    Posts
    1,663
    <BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR>where &lt;FIELDNAME&gt; like '%&lt;SEARCHTERM&gt;%' <HR></BLOCKQUOTE>
    Oh, for crying out load. Never knew you could use the % as a wildcard before the search term when using "Like" in the Where clause.

    Works perfectly.

    Thans Popdawg. The next round's on me.

    Wayne

  4. #4
    ABW Ambassador
    Join Date
    January 18th, 2005
    Posts
    673
    Just a quick note...

    Dont bother putting any kind of INDEX on a field that you use 'like %word%' with. Using a % in the front negates the use of any kind of index; the server is forced to do a table scan.

  5. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Can't find string terminator
    By aquafind in forum Cusimano.com Scripts
    Replies: 1
    Last Post: September 13th, 2007, 09:16 PM
  2. Web Developer ASP / ASP.NET and PHP.
    By Murray Newlands in forum Job Postings
    Replies: 0
    Last Post: July 24th, 2007, 05:23 AM
  3. Need ASP.NET and SQL Server 2005 Hosting
    By johnnyWebAffiliate in forum Domains & Hosting
    Replies: 1
    Last Post: October 14th, 2006, 11:58 PM

Posting Permissions

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