I am trying to obtain a list of speed values from my table in my database. I was wondering if their was an SQL command/method which would allow me to pass a list of CharIDs in the WHERE function, so that I would not have to create a FOR loop and carry out the four searches separately.
party_ids= [4, 3, 1, 2]
def initializegame(party_ids):
#Get selected party members IDS
print(party_ids)
#Obtain Speeds
fetchspeed=("SELECT startspeed FROM characters WHERE CharID=%s")
print(fetchspeed)
mycursor.execute(fetchspeed,party_ids)
myspeeds=mycursor.fetchall()
print(myspeeds)
print("done")
I'm relatively new to SQL and I may be missing something major.
I did try: passing a list to a where clause Yet that was a little too hard to follow.
Thanks in advance