0

Put simply, I want to be able to output just the number from the list returned without the brackets and commas. Here's what I mean.

mycursor = mydb.cursor()
mycursor.execute("SELECT staffID FROM staff_logins")
myresult = mycursor.fetchall()

for x in myresult:
    print (x)

This is connected to a MySQL database, and outputs this:

(1,)
(2,)
(3,)
(4,)
(5,)

This is the primary key for my database, so how would I make it so it outputs just the number without the commas and brackets so I just get the integer and use if statements with the numbers eg. (doesn't work for me)

    if x == 1:
        print ("number 1")

currently this doesnt work for me, so is there something I need to do to turn this into a proper integer without the comma. Sorry if this is a silly question but i appreciate any help in advance

Shephard_
  • 31
  • 4

0 Answers0