This is my code:
import mysql.connector
mydb = mysql.connector.connect(host='localhost',
database='glabo',
user='root',
password='.........')
mycursor = mydb.cursor()
mycursor.execute("INSERT INTO orders (o_userid, o_labo, o_jour, o_heure) SELECT users.user_id, labos.l_id, jours.j_id, heures.h_id FROM users, labos, jours, heures WHERE users.user_name = 'Kbayad' AND labos.l_nom = 'LABO 1' AND jours.j_jour = 'Mardi' AND heures.h_heure = '10-12';")
After running this python code, I don't get any error but nothing changes in the database
JOINsyntax. Easier to write (without errors), easier to read (and maintain), and easier to convert to outer join if needed. (Not the answer, but still a good advice.)