O'Reilly logo

MySQL for Python by Albert Lukaszewski, PhD

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. SELECT Alternatives

We have already seen how to restrict the data that MySQL returns by using a WHERE clause. Rather than retrieve the entire table and sort through it in Python, we passed the burden onto the server. Using WHERE restricted the number of rows that match. This is just like when we specify columns instead of using an asterisk after SELECT—it saves us from receiving the entire record for every match.

WHERE causes MySQL to ignore any row that does not match our selection. Specifying the columns then indicates to MySQL, which parts of the affected rows to return. In addition to WHERE, MySQL supports other ways of narrowing one's returns. It also allows us to match and complement the data using other tables, including combining ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required