Re: SELECT LIKE with "%" and without "%"
| From: | Philip Thompson | Date: | Mon, 04 May 2009 13:30:37 +0000 |
| Subject: | Re: SELECT LIKE with "%" and without "%" | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-46169@lists.php.net to get a copy of this message | ||
On May 2, 2009, at 6:43 PM, Emiliano Boragina wrote:
Hello. I am using this: $sql = "SELECT * FROM table WHERE ID LIKE '%$_GET[id]%' AND title LIKE '%$_GET[word]%'"; But I want exactlu ID, not one part of many possibles Ids in the DB. How can I do that?PLEASE tell me your cleaning that input... http://php.net/mysql_real_escape_string And to answer your question: <?php $id = mysql_real_escape_string ($_GET['id']); $word = mysql_real_escape_string ($_GET['word']); $sql = "SELECT * FROM
table WHERE ID = '$id' AND title = '$word'";
?>
Read more on MySQL's "LIKE" functionality. Google can help you.
HTH,
~Philip