searching on a wildcard

  • tommya
  • Graduate
  • Graduate
  • tommya
  • Posts: 221
  • Loc: United Kingdom

Post 3+ Months Ago

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
  • veedee
  • Graduate
  • Graduate
  • User avatar
  • Posts: 110

Post 3+ Months Ago

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

Post 3+ Months Ago

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
  • Cafu
  • Posts: 97

Post 3+ Months Ago

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
  • Posts: 110

Post 3+ Months Ago

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
  • tommya
  • Posts: 221
  • Loc: United Kingdom

Post 3+ Months Ago

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: Liamw411 and 116 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.