Query Builder: Sorting and Filtering

To generate a usable query the example shown on the previous page will need to have 'something' added. At least you would probably SORT and FILTER the data shown in the resultset using the SQL 'ORDER BY' and 'WHERE' clauses.

Sorting: To define the sort order of data you enter a number in the 'sort order' row of the GRID. The lowest number will be the sort criteria given highest priority (the fist column in the ORDER BY clause). The 'next-lowest number will be the sort criteria given 2nd priority and so on. For every column that shall be sorted you also enter if sorting on that column shall be done Ascending or Descending.

Filtering: Filtering data is done by entering criteria in the 'criteria' rows of the GRID. You can use all operators recognized by MySQL like ">" (greater than) for numbers and time-type variables, "LIKE 'something'" for strings, "IS (NOT) NULL" for all types of data etc. If you add more criteria, criteria in the same row of the GRID will be logically 'AND''ed' while criteria added in different rows of the same column of the GRID, the resulting criteria for each row will be logically 'OR'ed'.

The example below illustrates all this:

In this example we first sort descending on 'release_year'. For those data in the result where 'name' is the same the 4th sort order takes effect: they will be sorted (ascending) on 'film_id'. And if there should be some data having the same values for both 'release_year' and 'film_id' the result will be sorted alphabetically on 'film'.

In this example 'release_year' is a YEAR type. So if we only want to display data related to 'film' whose 'release_year' in the year of 2009 and before we can use the criteria '<=2009-01-26'.

Note: This feature is available in SQLyog Enterprise and Ultimate.

Still need help? Contact Us Contact Us