Query Builder

The Query Builder enables you to interactively build and execute simple queries on a table or a view without having to write any SQL code. This is distinct from the SQL Editor which allows you to create ands execute any SQL statements you want, but you have to understand the SQL syntax and semantics to use it. It is also distinct from the Find dialog which allows you to redisplay the current table (it doesn't work on a view or the result of a query), with only the rows which match a simple query visible (and editable). The result of a query cannot be edited because sqlite only allows you to edit real tables.

The Query Builder dialog is persistent through an sqliteman session. It is still there even if it is not being shown, and it remembers the last query that you built with it: this means that query will reappear if you open the dialog again unless you do something which would modify the table or view being queried, or you query a different one. This can be useful if you did not get your query quite right and want to modify it. Pressing the Reset button will remove the old query if you want to create a completely new one.

Database Name
If you invoked the Query Builder from the Context Menu, this field will be prefilled with the relevant Database name. If you invoked it from the Database Menu, and there is more than one database, you can select a database from the dropdown list.
Table Name
If you invoked the Query Builder from the Context Menu of a table or a view, this field will be prefilled with the name of the table or view. If you invoked it from the Database Menu or the Context Menu of a particualr database, you can select a table or a view in the chosen Database (if it contains more than one) from the dropdown list.
Fields tab
Query Fields

This tab allows you to choose the columns selected in your query. The left box lists the names of the columns not selected and the right box lists the names of the columns selected. You can move a column name by double-clicking on its name or move several column names by clicking on them and then clicking on one of the arrow buttons in the middle. Clicking on the double left arrow will remove all column names from the selected box. Clicking on the double right arrow will move all remaining column names except the rowid, which isn't usually wanted, to the selected box.

The order of the column names in the selected box will become the order of the columns in the query result. Sqlite allows a column to appear more than once in a query result, but this Query Builder does not (currently) enable you to build such a query.

Terms tab
Query Terms

This tab allows you to add match conditions to your query. If you add several match conditions you can choose whether the query returns rows which match all of them or rows which match any of them. The More button adds another match condition

Trem Added

For each match condition added: the leftmost dropdown list allows you to select a column to test and you can select any column in the table, including those which were not selected in the fields tab; the dropdown list in the middle allows you to select a test from Contains, Doesn't contain, Starts with, Equals, Not equals, Bigger than, Smaller than, Is null, and Is not null; the text input field at the right (not shown for Is null and Is not null) allows you to type in a comparison value.

For the Bigger than and Smaller than comparisons, if the comparison value and the actual value from the table are both numbers, a numeric comparison will be done, and otherwise a string comparison will be done.

The Less button deletes the last match condition.

Order By tab
Query Order

This tab allows you to add ordering requirements to your query output. If you add several ordering requirements, they will be applied in the sequence listed. The More button adds another ordering requirement and the Less button deletes the last ordering requirement.

Reset

This button resets the query to the default state with no columns selected, no match conditions (every row will match), and no ordering requirements. Changing the table name will also force a reset.

Copy SQL

This button copies to the clipboard the SQL statement that the query builder would execute. It can then be pasted into the SQL Editor or some other document.

OK

This button executes the query and dismisses the dialog.

Cancel

This button dismisses the dialog without executing the query. Any changes made to the query are still remembered.


Prev QueryBuilder.html> Next
Schema Browser Contents SQL Editor