w3resource

MySQL greater than operator

greater than operator

MySQL greater than operator checks whether an expression is greater than another expression.

Syntax:

>

MySQL Version: 8.0

Example: MySQL greater than operator

The following MySQL statement will fetch those publishers from the publisher table who have more than 10 branch offices.

Sample table: publisher


Code:


-- This query selects specific columns from the 'publisher' table where the number of branches is greater than 10.
SELECT pub_name, country, pub_city, no_of_branch 
-- This statement specifies the columns to be retrieved: 'pub_name', 'country', 'pub_city', and 'no_of_branch'.
FROM publisher
-- This part of the query specifies the table from which data is being retrieved, which is 'publisher'.
WHERE no_of_branch > 10;
-- This clause filters the rows to include only those where the 'no_of_branch' column has a value greater than 10.

Explanation:

  • The purpose of this SQL query is to retrieve information about publishers that have more than 10 branches.

  • SELECT pub_name, country, pub_city, no_of_branch: This part of the query specifies the columns to be selected from the 'publisher' table. It includes the publisher's name (pub_name), country (country), city (pub_city), and the number of branches (no_of_branch).

  • FROM publisher: This part specifies the table from which the data is being selected, which is the 'publisher' table.

  • WHERE no_of_branch > 10: This clause filters the results to include only those rows where the no_of_branch column has a value greater than 10. This ensures that only publishers with more than 10 branches are included in the results.

Output:

mysql> SELECT pub_name,country,pub_city,no_of_branch 
    -> FROM publisher
    -> WHERE no_of_branch>10;
+----------------------+---------+----------+--------------+
| pub_name             | country | pub_city | no_of_branch |
+----------------------+---------+----------+--------------+
| Jex Max Publication  | USA     | New York |           15 | 
| Mountain Publication | USA     | Houstan  |           25 | 
+----------------------+---------+----------+--------------+
2 rows in set (0.00 sec)

Relational Algebra Expression:

Relational Algebra Expression: MySQL greater than operator.

Relational Algebra Tree:

Relational Algebra Tree: MySQL greater than operator.

Slideshow of MySQL Comparison Function and Operators

Previous: Greater than or equal operator(>=)
Next: GREATEST()



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/mysql/comparision-functions-and-operators/greater-than-operator.php