How to make "Dummy" ORDER BY in MySQL?

I have a query like this:

SELECT * FROM blah1 WHERE blah2 ORDERBY %s

where I replace the string (sanitized!) for %s. The problem is that the string may be empty. How to insert no-op there if the line is empty, instead of changing the rest of the query?

+3
source share
2 answers

I think it should work for you: ORDER BY NULL

+4
source

Fixed line or number ( 1, 0, 'noop') <= do sent it with quotes.

+1
source

All Articles