# Method Mysql.SqlTable()->select()

Method select

  `Result select(string|array where, void|array(string) fields, void|string|array select_exprs, void|string table_refs, void|string|array rest, void|string select_flags)`

Description

  Retrieves all records that matches a condition.

  This function sends a SELECT statement, and it gives full expressive power to send any SELECT that is based on this table.

  The only functionality this function adds over Sql.big_typed_query is conversion of TIMESTAMP values (see the class doc), and the (optional) handling of arbitrary properties in addition to the SQL columns. fields may list such properties, and they are returned alongside the real columns. Properties cannot be used in WHERE expressions etc, though.

  Joins with other tables are possible through table_refs, but property columns in those tables aren't decoded.

Parameter `where`

  The match condition, on the form of a WHERE expression. It may be given as an array to use bindings or `sprintf`-style formatting - see handle_argspec for details.

  A WHERE clause will always be generated, but you can put e.g. "TRUE" in the match condition to select all records.

Parameter `fields`

  The fields to retrieve. All fields are retrieved if it's zero or left out.

  For columns, the result mappings always have corresponding entries. Other fields, i.e. properties, only occur in the result mappings when they match fields in the prop_col column.

  A `0` (zero) entry can be used in fields to return all properties without filtering.

Parameter `select_exprs`

  Optional extra select expression besides the requested columns. This is just added to the list of selected columns, after a separating ",".

  select_exprs may be given as an array to use bindings or `sprintf`-style formatting - see handle_argspec for details.

  Note that expressions in select_exprs that produce TIMESTAMP values are not converted to unix time integers - they are instead returned as formatted date/time strings.

Parameter `table_refs`

  Optional other tables to join into the SELECT. This is inserted between "FROM table" and "WHERE".

Parameter `rest`

  Optional clauses that follows after the WHERE clause, e.g. ORDER BY, GROUP BY, and LIMIT. It may be given as an array to use bindings or `sprintf`-style formatting - see handle_argspec for details.

Parameter `select_flags`

  Flags for the SELECT statement. If this string is given, it is simply inserted directly after the "SELECT" keyword.

Returns

  Returns a SqlTable.Result object from which the results can be retrieved. Zero is never returned.

Note

  The result object implements an iterator, so it can be used directly in e.g. a `foreach`.

Note

  quote may be used to quote string literals if the `sprintf`-style formats aren't used.

See also

  select1, get, get_multi