开发者

MySQL shortest query without results

I'm looking for a query with the lowest possible resource usage which gives no result. For example (this won't work):

SELECT 1 WHERE 0

Edit: The goal开发者_Python百科 would be to be used in an EXISTS subquery in special cases where I want no matches. (I know this is not the only possible solution, but in my environment I chose to use this one).


SELECT 1 FROM DUAL WHERE 0

will do the job; you will not even need a USE-statement before.


select '1' from tableName where 0


SELECT 1; would work but it gives a result set
You could try SELECT NULL from <any table>
A USE <database name> statement gives no result and takes up minimal resources.

What is this for exactly?


Perhaps you could do

select 1 where 1=0
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜