w3resource logo


MySQL less than or equal operator

MySQL less than or equal operator

rating Average rating 8 out of 10. Total 7 users rated.

<<PreviousNext>>

Description

MySQL less than or equal operator checks whether an expression is either less than or equal to another expression.

Syntax

<=

MySQL Version : 5.6


Example :

Sample table : publisher

The following MySQL statement will fetch those publishers form the publisher table who have less than or equal to 6 branch offices.

SELECT pub_name,country,pub_city,no_of_branch
FROM publisher       
WHERE no_of_branch<=6;

Output

MYSQL LESS THAN OR EQUAL OPERATOR

PHP script

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>example-less-than-or-equal-operator- php mysql examples | w3resource</title>
</head>
<body>
<?php
echo "<h2>List of publishers whose number of branches are six or less, along with their country, city and number of branches :</h2>";
echo "<table border='1' style='border-collapse: collapse;border-color: silver;'>";
echo "<tr style='font-weight: bold;'>";
echo "<td width='250' align='center'>Publisher</td><td width='250' align='center'>Country</td><td width='250' align='center'>City</td><td width='250' align='center'>Number of branches</td>";
echo "</tr>";
include("../dbopen.php");
$result = mysql_query("SELECT pub_name,country,pub_city,no_of_branch
FROM publisher
WHERE no_of_branch<=6");
while($row=mysql_fetch_array($result))
{
echo "<tr>";
echo "<td align='center' width='200'>" . $row['pub_name'] . "</td>";
echo "<td align='center' width='200'>" . $row['country'] . "</td>";
echo "<td align='center' width='200'>" . $row['pub_city'] . "</td>";
echo "<td align='center' width='200'>" . $row['no_of_branch'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
</body>
</html>

View the example in browser



We have compiled a number of MySQL Questions and Answers. Check and assess you MySQL skill by visiting those questions and answers.

<<PreviousNext>>