我可以在一个查询中从表中更新/选择吗? [英] Can I update/select from a table in one query?

查看:67
本文介绍了我可以在一个查询中从表中更新/选择吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看页面时我需要选择数据并更新视图"列,是否可以在一个查询中做到这一点,还是必须使用不同的查询?

I need to select data when a page is viewed and update the 'views' column is there a way to do this in one query, or do I have to use to distinct queries?

推荐答案

如果您不想/不需要使用事务,则可以创建一个存储过程,该存储过程首先更新视图计数,然后选择值并将其返回给用户.

If you do not want/need to use a transaction, you could create a stored procedure that first updates the view count and then selects the values and return them to the user.

这篇关于我可以在一个查询中从表中更新/选择吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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