0

Here is weird question: do i make SELECT query that will always return nothing from some database?Preferably fast,but not necessary.

For example,i have some random table Events,and i can do that simple way,by looking for record that will probably never exist:

"SELECT * FROM Events WHERE EventName = 'ajsiLfjh28v0djkf9409fda'

But that is very ugly solution.Is there a better way to do it?I can't find anything,mostly because i am unsure what to look for.

2
  • Why are you trying to return nothing? Why query at all? Commented May 15, 2013 at 22:54
  • I have few classes where getting any kind of query results is crucial and don't want to change them,and i also can't just send them empty data. Commented May 15, 2013 at 23:04

3 Answers 3

1

You can build on this basic empty query:

select 0 where 0;

You can make any query return nothing by throwing AND 0 at the end of the where clause (unless there is no where clause.)

Sign up to request clarification or add additional context in comments.

Comments

1

I really don't understand but if you want to make sure no result s are returned add a limit of 0

SELECT * FROM Events LIMIT 0

Comments

0

How about

SELECT * FROM Events WHERE null!=null

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.