Is this possible to return all columns in query as empty column (not null) or empty row, in case the actual query is returning no rows
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Generally, if you must have an empty row returned..
If your original query is
select a,b,c from tbl
You can turn it into a subquery
select t.a,t.b,t.c
from (select 1 as adummy) a
left join (
select a,b,c from tbl -- original query
) t on 1=1
Which ensures the query will always have a rowcount of at least one.
回答2:
If your objective is to return a query with no records, or with an empty recordset/dataset, the following should work without any previous knowledge on the original query:
SELECT * FROM (myOriginalQuery) as mySelect WHERE 0 = 1