Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将mysql if基于条件的值插入转换为postgresql_Mysql_Postgresql_Insert_Conditional Statements - Fatal编程技术网

如何将mysql if基于条件的值插入转换为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

上面的查询是基于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, market_fk)
select now(), 
       case  
          when ? = '''' then null
          else (select m.id from market m where m.name = ?)
       end;