Jump to content


Photo

Searching data where field has a spesific field in an spesific area


  • Please log in to reply
3 replies to this topic

#1 GremlinP1R

GremlinP1R
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts
  • LocationSouth Africa

Posted 10 October 2006 - 11:22 AM

Hi There.

Im trying to search my database in one spesific row where the number must contain xx number in a certain space like 85xx87643 it must always be in that position, where everything aroun the xx might change.
Can any one help me please.

SELECT * FROM table WHERE row LIKE ?

there I do not know how to put it. I tryed wildcards (%) but that surge thru the whole number of the xx.

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 10 October 2006 - 12:04 PM

In MySQL you can use two wildcard characters, you know one of them, that's the percent sign (%) the other is the underscore (_).  The percent sign matches any number of characters, whereas the underscore matches one single character.

$sql = "SELECT * FROM table WHERE column LIKE '__xx____'";

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 GremlinP1R

GremlinP1R
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts
  • LocationSouth Africa

Posted 10 October 2006 - 12:09 PM

Thanx again Huggie.

Your my hero today. LOL

#4 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 10 October 2006 - 12:13 PM

No problem, incidently, I found that information out myself by looking at the MySQL manual.

The link for which can be found in my signature.  I just did a search for wildcard AND like

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users