searching on a wildcard

  • tommya
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Mar 17, 2004
  • Posts: 221
  • Loc: United Kingdom
  • Status: Offline

Post July 28th, 2004, 7:27 am

assume that in the code below, 'a' is a string passed from a search form
How can i get it to search a mysql field on that string, because in the example below, it would only return those records that matched the string exactly i.e all records with a requestDetails value of 'a'

Code: [ Select ]
"SELECT * FROM problems WHERE requestDetails = 'a' ORDER BY callReference DESC";


I want it to return all records that have an 'a' anywhere in it
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 28th, 2004, 7:27 am

  • veedee
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jul 09, 2004
  • Posts: 110
  • Status: Offline

Post July 28th, 2004, 8:46 am

is it what you're looking for?
Code: [ Select ]
"SELECT * FROM problems WHERE requestDetails like '%a%' ORDER BY callReference DESC";
  • tommya
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Mar 17, 2004
  • Posts: 221
  • Loc: United Kingdom
  • Status: Offline

Post July 28th, 2004, 8:53 am

tried the following

Code: [ Select ]
SELECT * FROM problems WHERE requestDetails = '%display%'


where I know at least one record has the word display in the field I am searching, and it came back no result

any other thoughts?
  • Cafu
  • Student
  • Student
  • No Avatar
  • Joined: Jul 15, 2004
  • Posts: 97
  • Status: Offline

Post July 28th, 2004, 10:10 am

I think veedee's suggestion is what you are looking for.

Try replacing the equal sign in your query with the word LIKE
  • veedee
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jul 09, 2004
  • Posts: 110
  • Status: Offline

Post July 28th, 2004, 7:26 pm

Cafu wrote:
I think veedee's suggestion is what you are looking for.

Try replacing the equal sign in your query with the word LIKE

He did'nt realize, somebody posted a reply. We posted almost the same time..... :lol:
  • tommya
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Mar 17, 2004
  • Posts: 221
  • Loc: United Kingdom
  • Status: Offline

Post July 29th, 2004, 12:46 am

thanks guys, I have tried it and it is working great, another problem solved

:D

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 152 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.