Using the Query Editor

Editing the Query Parts

Each query is made up of 3-4 parts. All queries have SELECT, WHERE, and ORDER BY parts that are editable. When connected to MySQL, a LIMIT part is also available.

Elements in the Query Parts table may be re-arranged via drag & drop within the same part (i.e. SELECT columns can not be added to the WHERE part). Elements may be deleted by selecting them in the query party table and pressing the delete key.

SELECT part

When the SELECT query part (or any item in it) is selected, a browser is displayed with the list of available columns. Relationship contents will also be listed, as seen in the picture above. The quantity column from the invoiceitems relationship has been added to the list of columns to select. Note that relationships are not limited to a single level of depth—invoiceitems.product.name crosses two relationships.

WHERE part

The WHERE query part is made up of two types of objects: groups and conditions. A group is either an AND group or an OR group. The WHERE query part contains a single where group which may then contain any number of conditions and nested groups. Conditions may be added by selecting one of the conditions to place in that group and then pressing either the or buttons.

There are two types of conditions that may be added. A constructed condition is created by selecting a column, an operator, and entering a value to compare against. For text-based columns, MacSQL offers the operators of equals, not equal, contains, starts with, ends with, like and the standard numerical operators. For the contains, starts with, and ends with operators, MacSQL converts those into the appropriate like statement.

The second type of condition is a manual condition. This is used when the constructed condition choices do not provide the functionality you need. You may enter any valid SQL condition and it will be inserted into the query just like a constructed condition.

Conditions can be moved between groups by drag & drop. Groups can also be nested the same way. Any time there is a group contained in a group and neither group has any other conditions or groups, the outer group will be removed.

ORDER BY part

The ORDER BY query part is identical to the SELECT part, except radio button appear below the browser to allow specifying if each column is ordered ascending or descending.

LIMIT part

For MySQL queries the number of rows returned can be limited by entering a number in the LIMIT part.



Table of Contents