# Querying a Database

You can issue queries against the items currently displayed in the database. In Track and Album databases, queries are typically used to obtain counts of information. Query results are displayed in the Log Viewer.

The Key column is the column which identifies the values you are matching. When you select Query from a database's context menu, the column in which you clicked is automatically selected for you. You can change the column if you wish.

You can elect to match Any Value, With Exact Match or Containing Value. Any Value always matches every item in the selected Key column. With Exact Match will match any item in the Key column which has the same value as the specified value. This value may be empty. Containing value will match any item in the Key column which contains the specified value. In this case the specified value may not be empty. With any of these options you can specify that matching is case insensitive.

For each item matched in the Key column you are attempting to accumulate information on data in the specified Data column. The Data column and the Key column may be the same. Note that when they are the same the redundant listing of the Key Column will be eliminated.

The data is output as a list of alphabetically ascending matched key values followed by a list of matched data values. You can choose how you want the data value list to be sorted.

You can opt to include the metadata for any one field associated with a matched data value. Every unique value of the specified data type will be displayed. If at list one metadata item for for any matched Data column item contains more than one entry, the metadata will be followed by [#], where # is the number of occurrences. As an example, if you're going to save the query results and reopen the file at a later date you could specify the File Path. You can always select a path and save it to the system clipboard. You can then open the associated file or files via File>Open Path in Clipboard. Be careful with this option. If your database contains 40000 tracks and as an example you are matching Any Artist - Genre, references to all tracks will be contained in the produced data.

Examples:

> Key Column Artist, Containing Value various (case insensitive), Data Column Genre
>   will return a list of all artists containing the value various. For each returned item a list of genres with counts will be displayed.
> Key Column Artist, Any Value (case insensitive), Data Column Artist
>   will return a list of all artists and the number of times each artist occurs in the database.
> Key Column Artist, Containing Value B.B. King (case insensitive), Data Column Album
>   will return a list of all unique artist fields containing B.B. King and a list of albums for each of these values.
> Key Column Results, Containing Value Any Value, Data Column Results, Display data for column Title
>   If you did a Look for Duplicates, based on track titles, the above query would return a list of all clusters of matched titles with a sub-listing of each title variant and its respective number of occurrences.