update PROD_IMPORT_FEELIST a set cust_ID = (select Cust_ID
from Prod_Cust_info where a.USERNAME = b.CUST_NAME)
WHERE a.import_operid = t_head_operid and cust_id is null这样可以更新PROD_IMPORT_FEELIST表中的数据,但是如果Prod_Cust_info里的USERNAME如果有相同的话,那么肯定不是唯一的CUST_ID 系统报错:单行子查询返回多于一个行,这时候应该怎么写这个orcal,如果发现cust_id 大于1条数据时候,那我则不更新PROD_IMPORT_FEELIST的CUST_ID,让他为空
from Prod_Cust_info where a.USERNAME = b.CUST_NAME)
WHERE a.import_operid = t_head_operid and cust_id is null这样可以更新PROD_IMPORT_FEELIST表中的数据,但是如果Prod_Cust_info里的USERNAME如果有相同的话,那么肯定不是唯一的CUST_ID 系统报错:单行子查询返回多于一个行,这时候应该怎么写这个orcal,如果发现cust_id 大于1条数据时候,那我则不更新PROD_IMPORT_FEELIST的CUST_ID,让他为空
from Prod_Cust_info where a.USERNAME = b.CUST_NAME
--
and (select count(Cust_ID) from Prod_Cust_info where a.USERNAME = b.CUST_NAME))=1--
WHERE a.import_operid = t_head_operid and cust_id is null
SET cust_id = (SELECT cust_id
FROM prod_cust_info
WHERE a.username = b.cust_name)
WHERE a.import_operid = t_head_operid
AND cust_id IS NULL
AND a.username IN (SELECT cust_name
FROM prod_cust_info
GROUP BY cust_name
HAVING COUNT(*) = 1)
from Prod_Cust_info where a.USERNAME = b.CUST_NAME)
WHERE a.import_operid = t_head_operid and cust_id is null