FROMGRESQL,FROM中的子查询必须有别名

时间:2017-07-24 05:50:49

标签: postgresql

CREATE OR REPLACE FUNCTION sp_insert_nike_mapping_code ( shopId bigint ) RETURNS VOID AS $body$
BEGIN

    insert into temp_t_so_sales_order_push(so_code,seq)
   SELECT so_code,nextval('s_t_so_sales_order_push_code') from (
   SELECT so_code from t_so_sales_order_push where sync_status = 0 group by so_code
   );

   update t_so_sales_order_push pu
   set code = (
       SELECT temp.seq from temp_t_so_sales_order_push temp
       where temp.so_code = pu.so_code and pu.shop_id = shopId and pu.sync_status = 0
   )
   where exists(
          SELECT 1 from temp_t_so_sales_order_push temp
          where temp.so_code = pu.so_code and pu.shop_id = shopId and pu.sync_status = 0
   );
END
$body$
LANGUAGE PLPGSQL
SECURITY DEFINER
;

当我执行上面的代码时,得到了语法错误:FROM中的子查询必须有一个别名。 [错误]错误:FROM中的子查询必须有别名 第5行:...... ELECT so_code,nextval('s_t_so_sales_order_push_code')来自(                                                                       ^ 提示:例如,FROM(SELECT ...)[AS] foo。

有人帮助我吗?

1 个答案:

答案 0 :(得分:0)

$("#search").on("keyup", function() {
  var value = $(this).val();

  $("table tr").each(function(index) {
    if (index !== 0) {
      $row = $(this);

      var id = $row.find("td:first").text();

      if (id.indexOf(value) !== 0) {
        $row.hide();
      }
      else {
        $row.show();
      }
    }
  });
});