SQL query max(id)

SQL query max(id)

Postby tony » Mon Sep 16, 2013 7:40 am

Hello everyone I am new ;)

I'm working with mysql and I would like to be able to get the maximum value of a field.

The sql quesry is:
Code: Select all
sqlSelect = "SELECT max(id) FROM machines"

temp = 0
maxID = 0

for row in cursor.fetchall() :
    temp = row[0]
    print temp
    if (temp > maxID):

This code is works but is not good with a high number of data...
if i run in iPython
Code: Select all
SELECT max(id) FROM machines

the response il "1L"
there is the possibility to get the maximum value (without using iterations) like the mysql console/shell ?

Posts: 1
Joined: Mon Sep 16, 2013 7:26 am

Return to Networking

Who is online

Users browsing this forum: No registered users and 3 guests