如何将mysql if基于条件的值插入转换为postgresql
上面的查询是基于param值为market_fk插入值,它在MySQL中工作。如何将上述查询转换为postgresql?使用如何将mysql if基于条件的值插入转换为postgresql,mysql,postgresql,insert,conditional-statements,Mysql,Postgresql,Insert,Conditional Statements,上面的查询是基于param值为market_fk插入值,它在MySQL中工作。如何将上述查询转换为postgresql?使用插入。。。选择: insert into agreement_form set created = now(), market_fk = (if (? = '''', null, (select m.id from market m where m.name = ?))) insert into agreement_form (created, mar
插入。。。选择
:
insert into agreement_form
set created = now(),
market_fk = (if (? = '''', null, (select m.id from market m where m.name = ?)))
insert into agreement_form (created, market_fk)
select now(),
case
when ? = '''' then null
else (select m.id from market m where m.name = ?)
end;