Welcome to WebmasterWorld Guest from

Forum Moderators: brotherhood of lan & mack

Message Too Old, No Replies




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

10+ Year Member

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)

WebmasterWorld Senior Member 10+ Year Member


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)

10+ Year Member

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)

WebmasterWorld Senior Member 10+ Year Member

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.


Featured Threads

Hot Threads This Week

Hot Threads This Month