How to Get the Minimum and maximum Value of a Column of a MySQL Table Using Python? Last Updated : 23 Dec, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report Prerequisite: Python: MySQL Create Table In this article, we are going to see how to get the Minimum and Maximum Value of a Column of a MySQL Table Using Python. Python allows the integration of a wide range of database servers with applications. A database interface is required to access a database from Python. MySQL Connector-Python module is an API in python for communicating with a MySQL database. Database in use: We are going to use geeks(Database name) database and table describing the salary. Approach: Import module.Make a connection request with the database.Create an object for the database cursor.Execute the following MySQL query:SELECT MIN(Column_name) AS minimum FROM Table_name. SELECT MAX(Column_name) AS minimum FROM Table_name.And print the result. Example 1: Getting the minimum value of a column. Python3 # Establish connection to MySQL database import mysql.connector mydb = mysql.connector.connect( host = "localhost", user = "root", password = "root123", database = "geeks" ) # Create a cursor object cursor = mydb.cursor() # Execute the query cursor.execute("SELECT MIN(Value) AS minimum FROM salary") result = cursor.fetchall() for i in result: maximum= float(i[0]) print(maximum) # Close database connection mydb.close() Output: 200.0 Example 2: Getting the maximum value of a column. Python3 # Establish connection to MySQL database import mysql.connector mydb = mysql.connector.connect( host = "localhost", user = "root", password = "root123", database = "geeks" ) # Create a cursor object cursor = mydb.cursor() cursor.execute("SELECT MAX(Value) AS maximum FROM salary") result = cursor.fetchall() for i in result: maximum = float(i[0]) print(maximum) # Close database connection mydb.close() Output: 350030.0 Comment More infoAdvertise with us Next Article How to Get the minimum value from the Pandas dataframe in Python? K kumar_satyam Follow Improve Article Tags : Python Python-mySQL Practice Tags : python Similar Reads How to Compute the Average of a Column of a MySQL Table Using Python? A MySQL connector is needed to generate a connection between Python and the MySQL server. Here we will import mysql.connector library to get the average of the specified column in the given database. If you need to know how to install MySQL, see How to Install MySQL in Python 3. Average Function of 2 min read How to Concatenate Column Values of a MySQL Table Using Python? Prerequisite: Python: MySQL Create Table In this article, we show how to concatenate column values of a MySQL table using Python. We use various data types in SQL Server to define data in a particular column appropriately. We might have requirements to concatenate data from multiple columns into a s 2 min read How to Compute the Sum of All Rows of a Column of a MySQL Table Using Python? MySQL server is an open-source relational database management system that is a major support for web-based applications. Databases and related tables are the main component of many websites and applications as the data is stored and exchanged over the web. In order to access MySQL databases from a w 2 min read How to Add a Column to a MySQL Table in Python? Prerequisite: Python: MySQL Create Table Python allows the integration of a wide range of database servers with applications. A database interface is required to access a database from Python. MySQL Connector-Python module is an API in python for communicating with a MySQL database.  ALTER statemen 4 min read How to Get the minimum value from the Pandas dataframe in Python? In this article, we will discuss how to get the minimum value from the Pandas dataframe in Python. We can get the minimum value by using the min() function Syntax: dataframe.min(axis) where, axis=0 specifies columnaxis=1 specifies rowGet minimum value in dataframe row To get the minimum value in a 2 min read How to Get the maximum value from the Pandas dataframe in Python? Python Pandas max() function returns the maximum of the values over the requested axis. Syntax: dataframe.max(axis) where, axis=0 specifies columnaxis=1 specifies rowExample 1: Get maximum value in dataframe row To get the maximum value in a dataframe row simply call the max() function with axis set 2 min read Like