# Very basic ADQL 2.1 cheat sheet

## Examples

Use the Examples button at the bottom of this window!

Examples in the Service Provided submenu, if available,
relate to the current TAP service.

## SELECT statement:

    [WITH <name> AS (SELECT ...), ...]
    SELECT [TOP n] <select-list>
       FROM <table-and-join-expression>
       [WHERE <conditions>]
       [GROUP BY <column-list>]
       [HAVING <conditions>]
       [ORDER BY <column-list>]

    SELECT t.<col1> AS a, t.<col2> AS b FROM <table> AS t

    SELECT * FROM <table1> JOIN <table2> ON <expression>

## Comparison expressions

`<column> LIKE '%star%'` ('`%`' matches string, '`_`' matches single character)

    <column> = 0

    <column> IS NOT NULL

    <column> BETWEEN 0 AND 100

## Joins

    SELECT ... FROM <table1> JOIN <table2> ON <expression>

    SELECT ... FROM <table1> JOIN <table2> USING (<common-column-list>)

    SELECT ...
       FROM <table1> AS a
       JOIN <table2> AS b
       ON DISTANCE(a.ra, a.dec, b.ra, b.dec) <= <radius-in-degrees>

## Upload joins

Reference TOPCAT tables as `TAP_UPLOAD.t<n>`;
table 3 in Control Window list is `TAP_UPLOAD.t3`.

Not all services support upload joins.

## More help

GAVO ADQL Cheat Sheet (PDF, ADQL 2.0) (http://docs.g-vo.org/adqlref/)

GAVO ADQL Introduction (http://docs.g-vo.org/adql/)

ADQL 2.1 Standard (https://www.ivoa.net/documents/ADQL/20231215/)