MySQL
Compose a statement from a template, format one you already have, or look something up: every data type and what it costs, the built-in functions, everything a JSON column can do — including rewriting a condition for a column that has become one — and the SQL syntax itself. Everything is held in the browser and ends at the clipboard — no connection, no query, nothing sent anywhere.
44 of 44 entries
MySQL 8.0 unless an entry says otherwise · search matches names, keywords, descriptions and the notes.
Instructions
A MySQL crib sheet with a query builder attached — for the statement you write once a month and have to look up every time.
- Generate — pick a template on the left, fill in the table and field, and the statement builds as you type. A box you have not filled in yet shows as
<table>, so the shape stays readable. Copy SQL takes it away. - Format — paste a statement, or several separated by
;, and it comes back laid out, one clause per line. The options above the box choose the layout: indent by 2, 3, 4 or 8 spaces or by a tab; UPPER, lower or as-typed keywords, functions and data types (keywords UPPER, the other two as typed, by default); standard or tabular layout;AND/ORat the start or end of the line; how long a( … )may get before it is broken up; blank lines between statements; anda=1vsa = 1. - Data types — every column type in one table, grouped into integer, decimal, boolean, string, binary, date & time, JSON, spatial and the attributes you write beside them. Read down the Storage and Range columns to choose between them; click a row for the syntax, an example and the gotchas, or the ↗ beside a name for that type's page in the MySQL manual.
- Functions — search MySQL's built-ins by name or by what you want (
epoch,latest per group). Click one for its signature, the type it returns and a runnable example. - JSON — two halves of the one subject. Reference is everything a
JSONcolumn can do: path syntax,->and->>, every JSON function, how to index inside a document, and the traps. Convert takes aWHEREfragment written when the column was an ordinary one and gives back the version aJSONcolumn needs:`Meta`.URLSegment = '…'becomes`Meta`->>'$.URLSegment' = '…', andMeta = '{…}'becomes aCAST(… AS JSON). Name the column, or leave the box empty and it is guessed from what you pasted. - JSON → Filter builds the lines from scratch: name the JSON column (and the table, if the query joins), then add a row per condition — the key path (
URLSegment,a.b,items[0].name), its data type, and the check. A string can be=,contains(like '%…%'), starts / ends with, your ownlikepattern,in, empty or null; a number takes=,>=,betweenandin; a boolean is true or false. Rows are joined withAND, one per line. - Convert understands four checks beyond the comparisons:
IS NULL,IS NOT NULL, and — as shorthand it accepts on the way in —IS EMPTYandIS NOT EMPTY, meaning absent, JSONnull, or the empty string. Each expands to the real test, which is longer than what you typed for a reason: a JSONnullis not SQLNULL, so the obvious`Meta`->>'$.k' IS NULLreads a stored null as a value. - Basics — the SQL itself:
group by,distinct,left join,explain. Each entry ends with the gotchas.
Tips
- Nothing on this page runs a query. There is no connection and no server call — every button ends at your clipboard, so paste the statement into a client you trust and read it before you run it.
- Format changes whitespace and letter case, nothing else — string literals, backticked names, comments and
->>come back exactly as typed. Functions and data types are matched by name, so re-casing them also re-cases a table calledlogortext, and on a case-sensitive server that is a different table — which is why both default to as typed. SQL it cannot parse — an unclosed bracket or quote — gets the line and column of the problem instead of a guess, and a script withDELIMITERlines is refused rather than broken. update-safeliftsSQL_SAFE_UPDATESfor one connection, which is why it is copy-only: it has to run in the same session as the UPDATE that needs it.- Values you type are quoted before they reach the statement — a table or column goes in backtick-quoted, and a search value is escaped for a
'…'literal. A name that cannot be used says which rule it broke instead of being pasted in. - Convert changes the accesses and nothing else — the one exception being the four
IS …checks, which have to replace their operator to be right. Your value, your line breaks and your casing all come back as you typed them, and anything inside a string literal or a--comment is left alone, so alike '%…%'stays one, now on the key rather than on the whole document. What it cannot decide for you it says underneath: comparing to a number, and when a literal is not a document at all. - Each subject has one tab and one home, so nothing is stated twice: column types are on Data types, JSON is on JSON, and Basics is the syntax around them.
- Every group heading and every data type links out to its page in the official MySQL 8.0 reference manual on
dev.mysql.com. This tab is a way to choose between types, not the reference of record — when a number here matters, follow the ↗ and read the manual's wording. - Each tab has its own address (
/database/mysql/functions), so you can bookmark or share one. The template, your boxes and every search are kept in this browser, so a reload comes back where you left it. Nothing is shared with anyone else. - Hit Example and click a highlighted tab — each one loads its own sample, already open; on Format it pastes a one-line query and lays it out with your current options. On a reference tab the search box is highlighted too, and inside JSON Reference, Convert and Filter each carry their own sample, so the JSON tab shows you whichever view you are on.