--- id: select title: "Fetch data: select()" slug: select custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/dart.yml --- import Tabs from '@theme/Tabs'; import TabsPanel from '@theme/TabsPanel'; Performs vertical filtering with SELECT. ```dart final res = await supabase .from('cities') .select() .execute(); final data = res.data; final error = res.error; ``` ## Notes - By default, Supabase projects will return a maximum of 1,000 rows. This setting can be changed in Project API Settings. It's recommended that you keep it low to limit the payload size of accidental or malicious requests. You can use `range()` queries to paginate through your data. - `select()` can be combined with [Modifiers](/docs/reference/dart/using-modifiers) - `select()` can be combined with [Filters](/docs/reference/dart/using-filters) ## Examples ### Getting your data ```dart final res = await supabase .from('cities') .select() .execute(); final data = res.data; final error = res.error; ``` ### Selecting specific columns You can select specific fields from your tables. ```dart final res = await supabase .from('cities') .select('name') .execute(); ``` ### Query foreign tables If your database has relationships, you can query related tables too. ```dart final res = await supabase .from('countries') .select(''' name, cities ( name ) ''') .execute(); ``` ### Query the same foreign table multiple times Sometimes you will need to query the same foreign table twice. In this case, you can use the name of the joined column to identify which join you intend to use. For convenience, you can also give an alias for each column. For example, if we had a shop of products, and we wanted to get the supplier and the purchaser at the same time (both in the users) table: ```dart final res = await supabase .from('products') .select(''' id, supplier:supplier_id ( name ), purchaser:purchaser_id ( name ) ''') .execute(); ``` ### Filtering with inner joins If you want to filter a table based on a child table's values you can use the `!inner()` function. For example, if you wanted to select all rows in a `message` table which belong to a user with the `username` "Jane": ``` Not yet implemented ``` ### Querying with count option You can get the number of rows by using the count option. Allowed values for count option are [exact](https://postgrest.org/en/stable/api.html#exact-count), [planned](https://postgrest.org/en/stable/api.html#planned-count) and [estimated](https://postgrest.org/en/stable/api.html#estimated-count). ```dart final res = await supabase .from('cities') .select('name') .execute(count: CountOption.exact); final count = res.count; ``` ### Querying JSON data If you have data inside of a JSONB column, you can apply select and query filters to the data values. Postgres offers a [number of operators](https://www.postgresql.org/docs/current/functions-json.html) for querying JSON data. Also see [PostgREST docs](http://postgrest.org/en/v7.0.0/api.html#json-columns) for more details. ```dart final res = await supabase .from('users') .select(''' id, name, address->street ''') .eq('address->postcode', 90210) .execute(); ``` ### Return data as CSV By default the data is returned in JSON format, however you can also request for it to be returned as Comma Separated Values. ```dart final res = await supabase .from('users') .select() .csv() .execute(); ```