🔭SQL WHERE Clause Builder

List your conditions and get a WHERE clause with quotes escaped the standard way.

Operators accepted: = · != · <> · > · >= · < · <= · LIKE · NOT LIKE · IN · NOT IN · BETWEEN · IS NULL · IS NOT NULL. A column name must start with a letter or underscore and use letters, digits and underscores only; dotted names are accepted up to three parts. Anything else stops generation and names the line.

You Might Also Need

About this tool

Write a column, an operator and a value on each line and the tool assembles the WHERE clause. Choose whether the conditions are joined with AND or OR, pick the identifier quoting your database uses, and copy a clause that pastes straight into a query. The clause comes either with values written inline or with placeholders, so the version that goes into real code can be the bound one.

Single quotes inside values are doubled, which is the standard SQL escape. Backslash escaping is avoided because it behaves differently from one database to another. A column name passes only when it starts with a letter or underscore and uses letters, digits and underscores; anything else stops generation and names the offending line. A line that compares NULL with an equals sign is rewritten as IS NULL and the change is reported.

This tool builds the WHERE clause only. Table creation statements, extracting an IN list on its own and writing the sort clause are handled elsewhere. Subqueries, parenthesised nested conditions and function calls are not supported, so those have to be stitched in by hand.

Frequently asked questions

Why can NULL not be compared with an equals sign?

In SQL, NULL marks the absence of a value, so an equality test against it returns unknown rather than true or false. The condition never becomes true and no rows come back. IS NULL has to be used instead, and this tool rewrites such lines automatically.

Why offer a placeholder form as well?

Concatenating values into a string leaves injection open the moment one quote is missed. With placeholders the values never mix into the statement, so the bound form is the safer one to put into real code.

What does this tool not do?

It does not write table creation statements, extract IN lists on their own or build sort clauses. Subqueries, parenthesised nesting and function calls are unsupported.