Hello All,
Thanks in advance for reading this.
I am trying to use 'like' in a query_string for mysql,
but can't seem to incorporate the % properly.
For example, the actual sql is:
SELECT * FROM table WHERE date like '1999%'
(Needless to say it brings back all entries for 1999)
So, I need to construct a query string out of this, however the date
(which is formated in the table as yyyy-mm-dd) is a variable
for example:
$query_string = "SELECT * FROM table WHERE date like '$date'
HOW do I attach the % to the variable $date in this string?
thanks !
John[/b]
How can I attach % to a $variable in a query_string?
Moderator: General Moderators
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
-
penguinboy
- Forum Contributor
- Posts: 171
- Joined: Thu Nov 07, 2002 11:25 am
Code: Select all
$query_string = "SELECT * FROM table WHERE date LIKE '".$date."%'"