Shoutbox

MySQL Query WHERE With Wildcard - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: MySQL Query WHERE With Wildcard (/showthread.php?tid=36687)

MySQL Query WHERE With Wildcard by leito on 01-09-2005 at 02:40 AM

Can't get to work the wildcard in this query.

$sql = mysql_query("SELECT * FROM test1 WHERE points='14%'");

And in test1, I have many rows with values like 140, 142, 141, in the points column.

I was reading this tutorial http://www.tizag.com/mysqlTutorial/mysqlwhere.php, and I did exactly what they said there.


RE: MySQL Query WHERE With Wildcard by L. Coyote on 01-09-2005 at 02:44 AM

What type of data do you store in points? Int, text?

I think the wild cards worked on text... Can't remember, though...

edit:

I think it should be... WHERE points LIKE '14%'


RE: MySQL Query WHERE With Wildcard by leito on 01-09-2005 at 02:46 AM

Thank you for your response, well the type of the column is VARCHAR, and numbers are stored there.


RE: MySQL Query WHERE With Wildcard by L. Coyote on 01-09-2005 at 02:50 AM

quote:
Originally posted by leito.gt
Thank you for your response, well the type of the column is VARCHAR, and numbers are stored there.
Read my edit.

To use wildcards you must use LIKE.

column LIKE '%data%'

edit again: I didn't remember this at first :p
RE: MySQL Query WHERE With Wildcard by leito on 01-09-2005 at 02:53 AM

Thanks works great!