homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / WebmasterWorld / New To Web Development
Forum Library, Charter, Moderators: brotherhood of lan & mack

New To Web Development Forum


 4:16 pm on Sep 10, 2003 (gmt 0)

What sql statements wud be easiest way of searching through a database? Also so the search will allow parts of words to be found not certain words?


Purple Martin

 6:02 am on Sep 11, 2003 (gmt 0)


SELECT * FROM blah WHERE blah = 'blah' OR blah = 'blah'

For part-of-word searches, use LIKE instead of = and use % as a wildcard.


 10:04 am on Sep 11, 2003 (gmt 0)

FROM mysql.site
WHERE Fname like 'MMColParam%'

That works but only if i use the whole word? And if i wanted to use all the fields (Fname etc) would i use '*'

Purple Martin

 11:16 pm on Sep 11, 2003 (gmt 0)

You use * to return all fields.

To search all fields, you need to tell it to search each field in turn using OR:

SELECT blahField FROM blahTable WHERE field1 = 'blah' OR field2 = 'blah' OR ... etc

For part of a word: use part of the word and % as a wildcard. Look carefully at what you've got at the moment. It's looking for the whole word: if MMColParam is 'table', you'll be getting results that match 'table' plus any other characters, eg:
but not part of the word eg:

To return matches on part of the word, you have to search for part of the word, not the whole word. I hope that makes sense.

Global Options:
 top home search open messages active posts  

Home / Forums Index / WebmasterWorld / New To Web Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved