Before connecting MySQL
Prepare host, port, database name, username and password for a reachable MySQL server. TTSQL connects with MyXQL and can discover the schema available to that account; match the connection's TLS configuration to your server.
Confirm the server version before using CTEs or window functions. The examples below require MySQL 8.0 or later; a MySQL 5.7 deployment needs a different latest-row query.
Give the prompt the right dialect and context
MySQL uses backticks for quoted identifiers and single quotes for strings. Do not assume double quotes are identifiers unless ANSI_QUOTES is enabled. Table-name case sensitivity can vary with platform and server settings.
With ONLY_FULL_GROUP_BY enabled, selected nonaggregated columns must be grouped or functionally dependent on grouping columns. Make the output grain explicit instead of relying on permissive modes to choose an arbitrary row.
Schema used in these examples
customers(id INTEGER PRIMARY KEY, name TEXT, country TEXT); orders(id INTEGER PRIMARY KEY, customer_id INTEGER REFERENCES customers(id), ordered_at TIMESTAMP, status TEXT, total DECIMAL(12,2)). Each order has one customer. total is the order amount in a single reporting currency; paid means recognized revenue in this teaching dataset. Timestamps use UTC. These are example tables, not tables TTSQL creates.
Translate TEXT and TIMESTAMP to equivalent column types for your engine. Use your own database, schema and table qualifiers. Each example states its reporting grain and sorting rule.
Review these MySQL details
Apply range predicates directly to ordered_at when filtering a period, rather than wrapping every row in DATE_FORMAT. Formatting is appropriate for the displayed bucket but may prevent efficient filtering on an ordinary timestamp index.
MySQL TIMESTAMP values are converted through the session time zone, whereas DATETIME represents a stored date and time. Define the business time zone before interpreting month boundaries.
Generate, review, then choose whether to run
Select the matching database type and confirm your project's schema context before generating. Review the returned SQL against the schema and the metric you intended. A successful connection test does not prove that every table or operation is authorized.
TTSQL's POST /api/v1 endpoint generates SQL and returns executed: false. Query execution is a separate manual Run action in the workspace, subject to the configured connection and policies. The examples below are educational SELECT statements, not live results from your database.
Official MySQL references
Check your engine version and account configuration when adapting a function or connection setting.