icubesire

revenuehits

Search in Desigs Guru

Wednesday, March 9, 2011

The WHERE clause


The WHERE clause

The Santa Clause (Full Screen Special Edition)The WHERE clause is used to extract only those records that fulfill a specified criterion.
Syntax
SELECT column_name(s)
FROM table_name
WHERE column_name operator value

To learn more about SQL, please visit our SQL tutorial.

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

The following example selects all rows from the "Persons" table where "FirstName='Peter':
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("my_db", $con);

$result = mysql_query("SELECT * FROM Persons
WHERE FirstName='Peter'");

while($row = mysql_fetch_array($result))
  {
  echo $row['FirstName'] . " " . $row['LastName'];
Toddler XMAS Costume Santa Claus Clause Holiday Outfit Toddler (12-24 months)  echo "
";
  }
?>

The output of the code above will be:
Peter Griffin 

No comments:

Post a Comment

Thanks

LinkWithin

Related Posts Plugin for WordPress, Blogger...