How can I use a condition in PDO object while a query <p>I am trying to Select Data With PDO (+ Prepared Statements) The following example uses prepared statements.</p> <p><a href="http://www.w3schools.com/php/showphpfile.asp?filename=demo_db_select_pdo" rel="nofollow">http://www.w3schools.com/php/showphpfile.asp?filename=demo_db_select_pdo</a></p> <p>I need to know how to make a condition to display only the LASTNAME = PETER. I tried like the below, but not working</p> <pre><code>$stmt = $conn-&gt;prepare("SELECT id, firstname, lastname FROM MyGuests WHERE lastname =PETER"); </code></pre>