How can I attach % to a $variable in a query_string?
Posted: Fri Mar 19, 2004 1:43 pm
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]
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]