Chapter 12. Generating Multi-table Queries

The Search pages in the Database or Table view are intended for single-table lookups. This chapter covers the multi-table Query by example (QBE) feature available in the Database view.

Many phpMyAdmin users work in the Table view, table by table, and thus tend to overlook the multi-table query generator, which is a wonderful feature for fine-tuning queries. The query generator is useful not only in multi-table situations but also in single-table situations. It enables us to specify multiple criteria for a column, a feature that the Search page in the Table view does not possess.

Note

The examples in this chapter assume that a multi-user installation of the phpMyAdmin configuration storage has been made (refer to Chapter 1), and that the book-copy table created during an exercise of Chapter 9 is still there in the marc_book database.

To open the page for this feature, we go to the Database view for a specific database (the query generator supports working on only one database at a time) and click on Query.

The following screenshot shows the initial QBE page. It contains the following elements:

  • A visual builder link (covered at the end of this chapter)
  • Criteria columns
  • An interface to add criteria rows
  • An interface to add criteria columns
  • A table selector
  • The query area
  • Buttons to update or to execute the query
Generating Multi-table Queries

Choosing tables

The initial selection includes all tables. Consequently, the Column selector contains a great number of columns. For our example, we will work only with the author and the book tables. Hence, we select only these from the Use Tables selector.

We then click on the Update Query button. This refreshes the screen and reduces the number of columns available in the Column selector. We can always change the selected tables later, using our browser's mechanism for multiple choices in drop-down menus (usually control click).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.51.246