mysql - MySql,在 ON DUPLICATE KEY 内的子查询中使用值
问题描述
我有疑问:
Insert into target_counts
(target_id, email)
values (111, 'aa@aa.aa')
ON DUPLICATE KEY UPDATE
updated = NOW(),
ref_count= (SELECT Count(DISTINCT t.id)
FROM targets t
INNER join some_other_table sot on sot.target_id = t.id
sot.email = VALUES(email)
)
但有错误
'Unknown column 'email' in 'on clause''
是否有机会在 ON DUPLICATE KEY 子查询中使用 VALUES?
解决方案
推荐阅读
- laravel - Laravel 通知(一键获取详细信息)
- php - mysqli准备好的语句php
- javascript - 使用 javascript 删除重复值
- java - 摆动丢失异常
- java - 嗨,我可以在他或她在线时显示用户状态吗?反之亦然,在 android 中使用 firebase 可以显示用户状态吗?
- selenium - 从另一个 @Test 方法调用时如何在 TestNG 报告中显示 @Test 结果。请提出答案
- javascript - 拆分JS字符串正则表达式大写后跟小写
- java - Java 线程和异常处理
- python - Django - 在进程运行时显示 shell 输出命令
- azure-service-fabric - 在无状态服务的所有活动实例上调用相同的方法