Skip to main content

Practical Database Queries

  • Chapter
Beginning PHP and MySQL
  • 4558 Accesses

Abstract

The last several chapters served as an introduction to numerous concepts regarding using PHP and MySQL together to retrieve and manipulate data. This chapter expands your knowledge, demonstrating several challenges that you’re bound to repeatedly encounter while creating database-driven web applications. In particular, you’ll learn more about the following concepts:

  • Tabular output: Listing query results in an easily readable format is one of the most commonplace tasks you’ll deal with when building database-driven applications. This chapter explains how to programmatically create these listings.

  • Sorting tabular output: Often, query results are ordered in a default fashion, by product name, for example. But what if the user would like to reorder the results using some other criteria, such as price? You’ll learn how to provide table-sorting mechanisms that let the user search on any column.

  • Subqueries: Even simple data-driven applications often require queries to work with multiple tables, typically using joins. However, as you’ll learn, many of these operations can also be accomplished with the arguably much more intuitive subquery.

  • Cursors: Operating in a fashion similar to an array pointer, a cursor (a feature new to MySQL 5.0) gives you the ability to swiftly navigate database result sets. In this chapter you’ll learn how to use cursors to streamline your code.

  • Paged results: Database tables can consist of thousands, even millions, of records. When large result sets are retrieved, it often makes sense to separate these results across several pages and provide the user with a mechanism to navigate back and forth between these pages. This chapter explains how to do so.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 54.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 69.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Rights and permissions

Reprints and permissions

Copyright information

© 2010 W. Jason Gilmore

About this chapter

Cite this chapter

(2010). Practical Database Queries. In: Beginning PHP and MySQL. Apress. https://doi.org/10.1007/978-1-4302-3115-8_35

Download citation

Publish with us

Policies and ethics