Chapter 5. Writing Vfolder Queries.

Table of Contents
Basics
Fields to match.
More complex vfolder queries.
Tricks and Tips
Tuning the MYSQL database.

Basics

The Vfolders are SQL queries. But you only need to put in a small part of the query. Gmail builds a full SQL query around this. You only need to be putting in the criterior for what messages you want to match. Gmail will add all the other necessary commands for the query (eg: SELECT). See below for some examples.

Example 5-1. Show all incoming messages:

direction = "Incoming"

If you don't understand this example, it's time for you to return to Windows!

Example 5-2. Add the AND logic operator:

subject = "3D" AND direction = "Incoming"

This example searches all incoming messages with the subject "3D".

You can use other logical operators like OR as well. You can use round brackets to group items together.

Example 5-3. Get cleverer with the LIKE command:

subject LIKE "%3D%" AND direction = "Incoming"

This example searches all incoming messages with the subject that contains the text "3D".

Note the special SQL wildcard character is the percentage symbol: %

The wildcard character must be used in conjuction with the LIKE command. Together they will match any number of any characters.

Example 5-4. To match everything on the glx list:

subject LIKE "%[glx-dev]%" AND direction = "Incoming"

This is a real life example of how to match everything on a mailing list. In this case the glx-dev mailing list always puts it's name in the subject header. So we just need to search for that and we have created a vfolder for a mailing list!

A GUI query builder is probably coming soon, but you would hardly think it necessary with such great online docs. :)

Click on Next to see all the fields available for you in gmail to create vfolders with.