on
is for table joining, in this case I think you want to do something like this :
select '1101' as login_id,
a.project_id,a.user_id
from table1 as a
where a.user_id = '1101'
for the expect output you can use case
:
select '1001' as login_id,
case when user_id = '1001' then project_id else null end as project_id,
case when user_id = '1001' then user_id else null end as user_id
from table1
here is the db<>fiddle.
just saw the parameter part, just add a parameter which replace 1001
in the syntax and I think the result will be good. although I think keeping all those null data is a weird choose.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…