Re: mysql wildcard
| From: | janet at valade dot com | Date: | Wed, 08 Jan 2003 23:25:14 +0000 |
| Subject: | Re: mysql wildcard | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-24676@lists.php.net to get a copy of this message | ||
In a message dated 1/8/03 2:48:15 PM Pacific Standard
Time, epeloke@echoman.com writes:
<<I have an query:
select * from offtime where type='$type'
then I just pass the type variable to the page. Is
there a wildcard in mysql like there is in sqlserver
that I can use to grab all the records? such as select
* from offtime where type='%' would grab all. >>
Yes, MySQL has a wild card. It is % for a string of
characters or _ for a single character. You can say
things like where type like 'tp%'. However, if all you
want to do is get all the records from a table, you can
do that with:
SELECT * FROM offtime
Wild cards are used more for things like:
SELECT * FROM offtime WHERE type LIKE 'tp%'
You can also do pattern matching with regular
expressions using REGEXP
Janet
------------------
Janet Valade
author, PHP and MySQL for Dummies