homepage Welcome to WebmasterWorld Guest from 54.166.159.110
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / WebmasterWorld / New To Web Development
Forum Library, Charter, Moderators: brotherhood of lan & mack

New To Web Development Forum

    
Searching!
infernofiasco

10+ Year Member



 
Msg#: 801 posted 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

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 801 posted 6:02 am on Sep 11, 2003 (gmt 0)

Searching:

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

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

infernofiasco

10+ Year Member



 
Msg#: 801 posted 10:04 am on Sep 11, 2003 (gmt 0)

SELECT Fname
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

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 801 posted 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:
'table'
'tables'
'tabletop'
but not part of the word eg:
'tab'

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