Skip to Content
Learn SQL in a Month of Lunches
book

Learn SQL in a Month of Lunches

by Jeff Iannucci
February 2025
Beginner content levelBeginner
304 pages
8h 8m
English
Manning Publications
Content preview from Learn SQL in a Month of Lunches

22 Using cursors

In chapter 21, we explored making decisions in queries and learned how to make conditional evaluations. Using IF and THEN keywords allowed us to evaluate one or more values and then decide whether to do something else, such as insert a row of values into a table.

In this chapter, we’ll look at other ways to evaluate data and make decisions in SQL, focusing primarily on cursors. Cursors enable us to evaluate a set of data one row or value at a time. Also, as we’ll see, they have a bit of complexity, and there are important considerations regarding their use.

The use of cursors in MySQL is restricted to database objects containing prepared SQL, such as stored procedures. Because of this restriction, we’ll look at some previously ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, 4th Edition

SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, 4th Edition

John L. Viescas
SQL Cookbook, 2nd Edition

SQL Cookbook, 2nd Edition

Anthony Molinaro, Robert de Graaf

Publisher Resources

ISBN: 9781633438576Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentPurchase Link