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)

Python MySQL — Knowledge Check

Check your understanding of this section. Results are not saved—refresh the page to start over.

1. In SQL, SELECT is used to:
2. WHERE clause:
3. JOIN combines:
4. Parameterized queries in Python help prevent:
5. UPDATE without WHERE: