Alexander Gelbukh
Alexander Gelbukh

Reputation: 2240

MySQL query to do nothing (like pass)

Many languages have a construction that fills a syntactic position of a statement but has no effect: pass in Python, \relax in TeX, CONTINUE in Fortran, ; in C and Perl.

What is its equivalent in MySQL? That is, a query that would be syntactically correct but have no effect -- apart from confusing expressions like SELECT * FROM table LIMIT 0.

This is useful when the queries are generated automatically and at some point the generation procedure is expected to generate a query but there is no action to do.

Upvotes: 4

Views: 2601

Answers (4)

Tal
Tal

Reputation: 11

When doing from cli client you can also just call the quit function as you enter like this:

mysql -e '\q'

Upvotes: 0

Hortun
Hortun

Reputation: 11

DO 0; is another option for MySQL No-op.

Upvotes: 1

Filip Halaxa
Filip Halaxa

Reputation: 778

First what comes to mind is just SELECT null or something similar.

Edit: Unlike SELECT null, set @noop = null does nothig

Upvotes: 0

forpas
forpas

Reputation: 164089

This query:

SELECT 1 FROM DUAL WHERE false

or simpler in MySql 8.0+:

SELECT 1 WHERE false

return nothing, if this is what you mean when you say no effect.

Upvotes: 3

Related Questions