Python MySQL

MySQL Join

Joining tables

MySQL Join

You can combine rows from two or more tables, based on a related column between them, by using a JOIN statement.

Inner Join

sql = "SELECT     users.name AS user,     products.name AS favorite     FROM users     INNER JOIN products ON users.fav = products.id"

mycursor.execute(sql)
myresult = mycursor.fetchall()
for x in myresult:
    print(x)