gpt4 book ai didi

SQL 服务器 : Update a colum with Random Value

转载 作者:行者123 更新时间:2023-12-01 00:38:14 25 4
gpt4 key购买 nike

我有一个表 Product,其中有一列名为 Genre,其中包含空值/不需要的值。

我想用一组值更新该列:

Documentary
Comedy
Adventure/Action
Drama
Thriller
SF/Fantasy
Animation/Family
Others

更新可以按任何顺序进行,但我希望更新列中的每一行。我该怎么办?

最佳答案

尝试这样的事情

UPDATE P
SET genre = rand_values
FROM Product p
CROSS apply (SELECT TOP 1 rand_values
FROM (VALUES ('Documentary'),
('Comedy'),
('Adventure/Action'),
('Drama'),
('Thriller'),
('SF/Fantasy'),
('Animation/Family'),
('Others')) tc (rand_values)
WHERE p.productid = p.productid -- This is just to correlate the query
ORDER BY Newid()) cs

关于SQL 服务器 : Update a colum with Random Value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31857522/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com