sql输入条件没匹配的结果返回一行空

oracle :伪表dual左关联查询表,在关联时输入条件,返回空行。
select empno, &a ename
from dual a
left join scott.emp b
on 1 = 1
and ename = &a
mysql: 直接使用dual不行 ,用 (select 1 ) 或(select 1 from dual ) 构造个a表来左关联
set @var=‘localhost’;
select user, @var host
from (select 1 id )a
left join user b
on 1 = 1
and host=@var;
sqlserver:不存在dual,用(select 1 id)构造个a表,必须取个列名。
declare @var varchar(50)
set @var=‘master1’
select database_id, @var name
from (select 1 id )a
left join sys.databases b
on 1 = 1
and name=@var;
每种库的伪表借用图片:
sql输入条件没匹配的结果返回一行空_第1张图片

你可能感兴趣的:(sql输入条件没匹配的结果返回一行空)