Python Tutorials · Python MySQL
MySQL Select
Learn all about MySQL Select in this comprehensive tutorial.
5 min read advanced
- •To select from a table in MySQL, use the "SELECT" statement:
- •To select only some of the columns in a table, use the "SELECT" statement followed by the column name(s):
- •If you are only interested in one row, you can use the fetchone() method.
Select From a Table
To select from a table in MySQL, use the "SELECT" statement:
python
Note: Note: We use the fetchall()
method, which fetches all rows from the last executed statement.
Selecting Columns
To select only some of the columns in a table, use the "SELECT" statement followed by the column name(s):
python
Using the fetchone() Method
If you are only interested in one row, you can use the fetchone() method.
The fetchone() method will return the first row of the result:
python
Module quiz
Test your knowledge on this module
5 questions