Question:how to use where in the select-query?

The WHERE clause is used to filter records.

The WHERE clause

The WHERE clause is used to extract only those records that fulfill a specified criterion.


SELECT column_name(s)
FROM table_name
WHERE column_name operator value

To get PHP to execute the statement above we must use the mysqli_query() function. This function is used to send a query or command to a MySQL connection.


The following example selects all rows from the "Persons" table where "FirstName='Peter'":

// Check connection
if (mysqli_connect_errno())
  echo "Failed to connect to MySQL: " . mysqli_connect_error();

$result = mysqli_query($con,"SELECT * FROM Persons
WHERE FirstName='Peter'");

while($row = mysqli_fetch_array($result))
  echo $row['FirstName'] . " " . $row['LastName'];
  echo "


asked Sep 13, 2013 in PHP by rajesh
edited Sep 12, 2013
0 votes

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.