FROM clause
The FROM clause is used to specify the table or view to query. It can also be used to specify targets beyond just a single table or record name.
Syntax
Clause Syntax
STATEMENT
[FROM [ONLY] @targets;]
Data retrieval
One of the most common use cases for the FROM clause is to specify the table or view to query. You can use this clause to pull data from single or multiple tables.
All the ways you can use the FROM clause
SELECT * FROM user, admin;
LET $table = "user";
SELECT * FROM type::table($table) WHERE admin = true;
LET $table = "user";
LET $id = "admin";
SELECT * FROM type::record($table, $id);
SELECT * FROM user:tobie, user:jaime, company:surrealdb;
SELECT * FROM [3648937, "test", person:lrym5gur8hzws72ux5fa, person:4luro9170uwcv1xrfvby];
SELECT * FROM { person: person:lrym5gur8hzws72ux5fa, embedded: true };
SELECT * FROM (SELECT age >= 18 AS adult FROM user) WHERE adult = true;
Using the ONLY keyword
The ONLY keyword can be used to specify that only the specified targets should be retrieved. This is useful when you want to retrieve data from a single table or view. The ONLY keyword can be used in conjunction with the LIMIT clause to specify that only the specified number of records should be retrieved.
This keyword can be particularly useful with SDKs as it can guaranteed to have just a single object and that makes it nicer to deserialise.
Using the ONLY keyword
SELECT * FROM ONLY user:one;
SELECT * FROM ONLY user LIMIT 10;