开发者

Is it possible to Update single/multiple columns using "group by"

开发者 https://www.devze.com 2022-12-10 11:34 出处:网络
I am running group by on 4 columns of two tables. I have unique ID column in two tables. I want to mark both the tables occurrences column to SINGLE/MULTIPLE based on the 4 columns. Is there any w开发

I am running group by on 4 columns of two tables. I have unique ID column in two tables. I want to mark both the tables occurrences column to SINGLE/MULTIPLE based on the 4 columns. Is there any w开发者_C百科ay to update based on the results of group by?.


As longneck noted, your description is pretty vague.

However, to answer your question generally, it IS possible to run an update based on the results of another query:

UPDATE your_update_table
FROM your_update_table
JOIN
(
    # Insert your query (with GROUP BYs and all) here
) AS subquery_join ON subquery_join.id = your_update_table.id
SET your_update_table.column = subquery_join.some_value

A more explicit answer would require a more detailed explanation of the problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号