关于数据库查询的问题 [英] Question about database Query

查看:70
本文介绍了关于数据库查询的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在开发一个应用程序,因为我必须插入用户的注销时间

我启动sql update quey但是它用where关键字更新所有值。

假设abc@gmail.com今天登录并且今天退出所以更新查询是火,但是第二天abc@gmail.com在登出时登录我发了更新查询所以以前的记录也更新了所以如何才能解决这个问题?

Hello I am currently developing one application in that I have to insert the logout time of the user
I fire the sql update quey but It update all value with where keyword.
Suppose abc@gmail.com login today and it logout today so Update query is fire but next day abc@gmail.com login at the time of logout I fire the update query so previously record is also updated so how can I solve this problem?

推荐答案

我明白了你的意思。

您正在参考电子邮件ID进行更新。

remenber一件事永远不会那样。



您应该通过包含主键的注销表的最新ID更新注销时间。



所以你的sql查询就像那样... :)



I got your point.
You are doing updations with reference of Email ID.
remenber one thing never do that.

You should update logout time by Latest id of logout table which contains primary key.

So your sql query is like that...:)

update tableName set Logout=GETDATE() where id in(select max(id) from tableName )


这篇关于关于数据库查询的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆