SQL query converter
No sign-up. The query is converted in memory and not stored.
174 / 20,000
Questions
How do I convert a MySQL query to PostgreSQL?
Most of it is mechanical: IFNULL becomes COALESCE, GROUP_CONCAT becomes STRING_AGG, LIMIT 20, 10 becomes LIMIT 10 OFFSET 20, backticks become double quotes, INTERVAL 7 DAY becomes INTERVAL '7 DAY'. The part that breaks applications is behaviour that changes while the query still runs: string comparisons and LIKE stop ignoring case, NULLs sort last instead of first, and integer division stops returning decimals. This tool rewrites the first kind and tells you about the second.
Why did it add NULLS FIRST to my ORDER BY?
MySQL puts NULLs first in an ascending sort and PostgreSQL puts them last. Adding NULLS FIRST keeps the order the application was written against. Remove it if you prefer PostgreSQL's order.
Why does it say a query needs a rewrite by hand?
Some MySQL statements have no same-meaning equivalent: UPDATE or DELETE with ORDER BY and LIMIT, a GROUP BY that selects columns it does not group, ON DUPLICATE KEY UPDATE without knowing the table's key. Rather than emit something that runs and does something else, it says what to change.
Is an AI model involved?
No. The query is parsed into a syntax tree (sqlglot) and rewritten by fixed rules, so the same input always gives the same output. It is the same code DBShifts uses to convert the queries in an application during a migration.
Is my query stored?
No. It is converted in memory and returned; the request body is not logged or saved. Up to 20,000 characters, one statement at a time, 30 conversions a minute per network.
Convert every query in your application, not one at a time
DBShifts finds the SQL in your code, rewrites each statement with these same rules, and checks every rewrite against your new database with EXPLAIN — planned, never executed — before you ship it.