[SQL]UPDATE 语句中使用SELECT的结果
UPDATEADMIN_USERSETHASMSG=exp1IN(SELECTCOUNT(*)ASexp1FROMADMIN_MSGWHERERECEIVE=1ANDUN...
UPDATE ADMIN_USER
SET HASMSG = exp1 IN
(SELECT COUNT(*) AS exp1
FROM ADMIN_MSG
WHERE RECEIVE = 1 AND UNREAD = 1)
WHERE USERID = 1
上边是我胡写的
有2个表admin_user(hasmsg记录未读数),admin_msg(unread=1表示没读),将count(*) where unread=1的count(*) 更新到admin_user的hasmsg中
谢谢 展开
SET HASMSG = exp1 IN
(SELECT COUNT(*) AS exp1
FROM ADMIN_MSG
WHERE RECEIVE = 1 AND UNREAD = 1)
WHERE USERID = 1
上边是我胡写的
有2个表admin_user(hasmsg记录未读数),admin_msg(unread=1表示没读),将count(*) where unread=1的count(*) 更新到admin_user的hasmsg中
谢谢 展开
展开全部
UPDATE ADMIN_USER SET HASMSG =(SELECT COUNT(*)FROM ADMIN_MSG WHERE RECEIVE = 1 AND UNREAD = 1) WHERE USERID = 1 这就行了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询