Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/68.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 为缺少信息的客户端添加银行身份验证_Mysql_Sql - Fatal编程技术网

Mysql 为缺少信息的客户端添加银行身份验证

Mysql 为缺少信息的客户端添加银行身份验证,mysql,sql,Mysql,Sql,我有两张桌子 Clients(Id, LastName, FirstName) ClientBankAuth(Id, CreationDate, CLientId) 我需要找到所有客户,没有银行认证,并添加它 我尝试通过这个查询获取所有数据,它可以很好地返回客户机 SELECT * FROM clients c WHERE NOT EXISTS (SELECT 1 from clientbankauthentications cba where cba.ClientId=c.Id) 如何

我有两张桌子

Clients(Id, LastName, FirstName)

ClientBankAuth(Id, CreationDate, CLientId)
我需要找到所有客户,没有银行认证,并添加它

我尝试通过这个查询获取所有数据,它可以很好地返回客户机

 SELECT * FROM clients c
WHERE NOT EXISTS (SELECT 1 from clientbankauthentications cba where cba.ClientId=c.Id)

如何获取所有未进行身份验证的客户端并为每个客户端添加一个条目?

要选择所有未进行身份验证的客户端,请执行以下操作:

select * from clients c
where not exist (select 1 from ClientBankAuth cba where cba.clientid=c.clientid)
如果您的id列是自动生成的,则需要将缺少的客户端添加到ClientBankAuth

    insert into ClientBankAuth(creationdate,clientid)
    select now(),id from clients c
    where not exist (select 1 from ClientBankAuth cba where cba.clientid=c.clientid)

“添加”是什么意思?添加到“ClientBankAuth”?是的,我需要使用clientid和今天的日期向bank auth添加一个条目,因此,例如,id为1的客户没有auth,因此我需要使用此客户id向bank auth表添加一个条目,对于所有没有bank auth@KaziMohammadAliNurYes的客户,这是可行的,但是我如何才能为这个查询返回的每个客户添加银行认证条目呢?您的id列是自动递增的吗?是的,它是自动递增的。我已经修改了我的答案。