Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Member
    Join Date
    May 2004
    Location
    Hamilton, Ont, Canada
    Posts
    62
    Member #
    6097
    I know that you can use LIKE in a select statement to have the query look for related information in the database, but I heard that this can only look for one word, not a string. So it could look for "hello" but not "hello all".

    Is this true? Is this what you would use for a site search function? I heard there is another LIKE statement thats similar but looks for strings. Im just trying to create a search function and want to know whats best for comparing an entered search item against a database. Thanks in advance!

  2.  

  3. #2
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    How about...

    Code:
    SELECT ... FROM ... WHERE ... LIKE '%hello%' OR ... LIKE '%all%'
    or

    Code:
    SELECT ... FROM ... WHERE ... LIKE '%hello%' AND ... LIKE '%all%'
    or

    Code:
    SELECT ... FROM ... WHERE ... LIKE '%hello all%'
    ?
    JR

  4. #3
    Member
    Join Date
    May 2004
    Location
    Hamilton, Ont, Canada
    Posts
    62
    Member #
    6097
    Those look about how I imagined it. And that should work?

    Edit: What are the % symbols for?

  5. #4
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    They are so you can have any amount of characters before or after the string.
    JR

  6. #5
    Member
    Join Date
    May 2004
    Location
    Hamilton, Ont, Canada
    Posts
    62
    Member #
    6097
    Quote Originally Posted by JR
    They are so you can have any amount of characters before or after the string.
    Thanks, and one last question , I have to look into this more, but off hand do you know if there is some sort of "SORT BY/ORDER BY RELATIVITY" that would order the results from least to most, or most to least relativity to the search term?

  7. #6
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    I very much doubt it. That is something you'd need to do using PHP. If you're still interested there is bound to be loads of tutorials on the internet for creating searches, possibly some on this site.
    JR

  8. #7
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    S. Rosland


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:39 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com