A newer version of this documentation is available.

View Latest

LIMIT clause

LIMIT expression

The LIMIT clause specifies the maximum number of objects that can be returned in a result set by SELECT. A negative value or a value greater than 9223372036854775295 (result of math.MaxInt64`- 512`) is considered as LIMIT 0.

Starting from version 4.5, the LIMIT clause in DML statements is no longer a hint. It indicates that the actual number of mutations will be less than or equal to the specified LIMIT.
Query
SELECT t.name, t.address, t.city, t.country, t.url
FROM `travel-sample` t
WHERE type="hotel"
  AND t.vacancy = true
LIMIT 2;
Result
[
  {
    "address": "Capstone Road, ME7 3JE",
    "city": "Medway",
    "country": "United Kingdom",
    "name": "Medway Youth Hostel",
    "url": "http://www.yha.org.uk"
  },
  {
    "address": "6 rue aux Juifs",
    "city": "Giverny",
    "country": "France",
    "name": "The Robins",
    "url": "http://givernyguesthouse.com/robin.htm"
  }
]