Searching through a database

Results 1 to 4 of 4

Thread: Searching through a database

  1. #1
    Daniel Gilbert Guest

    Default Searching through a database

    I&#039m trying to have a query search a database and return any fields that have the words in it.<BR>ex. Searching for 1994 Ford Ranger<BR><BR>I want the results to bring any row that has the description for it if the description is Red Ford Ranger<BR><BR>Any help would be helpful

  2. #2
    Sharique Syed Guest

    Default RE: Searching through a database

    Can You please ellaborate your question.<BR><BR>Any way by now whatever I &#039ve understood of your question.<BR>The awnser is You can try like clause in your sql statement <BR><BR>E.g: "Select carmodel from cartable where carmodel like &#039ford&#039"<BR><BR>This will get you all the carmodel name which are having "ford" in their names.<BR><BR>Note:pls change tablename & colname in the statement according to your table.<BR><BR>Thank you.

  3. #3
    Daniel Gilbert Guest

    Default RE: Searching through a database

    Say the discription field says: 1994 ford ranger good condition<BR><BR>The user would type in ford for the input.<BR><BR>In the SQL i use like and it still doesn&#039t find anything.<BR>heres the SQL that I&#039m using<BR>mySQL="select * from trader where state=&#039" & mystate & "&#039 AND county=&#039" & mycounty & "&#039 AND description like &#039" & mydesc & "&#039" <BR><BR>Thanks for your help

  4. #4
    Cable Guest

    Default RE: Searching through a database

    For MS SQL Server try this:<BR><BR>mySQL="select * from trader where state=&#039" & mystate & "&#039 AND county=&#039" & mycounty & "&#039 AND description like &#039%" & mydesc & "%&#039" <BR><BR>The Percent signs indicate that you are searching for a description that contains the part of it like mydesc.<BR><BR>Or you can just search per word like the Hooray! Example at:<BR><BR>http://www.4guysfromrolla.com/webtech/072199-1.shtml<BR><BR>SQL = "SELECT tblEmployees.*, tblEmployees.Name, tblEmployees.Title, tblEmployees.Department "<BR>SQL = SQL & "FROM tblEmployees "<BR>SQL = SQL & "WHERE (((tblEmployees.Name) Like &#039%" & SearchText & "%&#039)) OR (((tblEmployees.Title) Like &#039%" & SearchText & "%&#039)) OR (((tblEmployees.Department) Like &#039%" & SearchText & "%&#039));" <BR><BR>Notice the % symbol around the search text. <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
  •