limit का use Database Table से limited records select करने के लिए किया जाता है।

# import connector class from mysql module.
import mysql.connector as myconn mydb = myconn.connect( host = 'localhost', user = 'root', password = '', database = 'python_db' ) db_cursor = mydb.cursor() # select only 2 records. query = "SELECT * FROM users LIMIT 2" db_cursor.execute(query) rows = db_cursor.fetchall() for row in rows : print(row)

Limit से आप सिर्फ records को select करने के limited records को update / delete भी कर सकते हैं।
For Example -

#delete 5 records.
query = "DELETE FROM users WHERE last_name=%s LIMIT 5" value = ('Singh', ) db_cursor.execute(query, value) #update only 3 records. query = "UPDATE users SET email = %s WHERE id=%s LIMIT 3" set_value = ('', 1) db_cursor.execute(query, set_value)

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.

Get connected with me. :) LinkedIn Twitter Instagram Facebook