Is there an easy and simple way to create a result table that has specified columns but zero rows? In set theory this is called an empty set, but since relational databases use multidimensional sets the term doesn’t fit perfectly. I have tried these two queries, but both deliver exactly one row and not zero rows:
- SELECT ” AS ID;
- SELECT null AS ID;
But what I want is the same result as this query:
- SELECT ID FROM sometable WHERE false;
I’m searching for a more elegant way because I don’t want to have a table involved, so the query is independent from any database scheme. Also a generic query might be a bit faster (not that it would matter for such a query).
Without any real tables.
Do note that most (My)SQL clients simply will display “Empty set”. However, it actually does what you want: