如果MYSQL返回空结果集,如何返回数据全部为NULL的行?
带有此数据的 article
表,
id title url
1 abc abc
查询,
SELECT*
FROM article
WHERE id = '2'
结果,
MySQL returned an empty result set (i.e. zero rows). (Query took 0.0010 sec)
我需要的结果,
id title url
NULL NULL NULL
有可能吗?
答案 0 :(得分:2)
select t2.*
from (select 1) t1 left join
article t2 on t2.id = 2
答案 1 :(得分:1)
SELECT *
FROM article
WHERE id = '2'
union all
select null, null, null
from dual
where not exists (select 1 from article where id = '2')