gpt4 book ai didi

sql - 如何在SQL中为表中的每一行随机输入DOB?

转载 作者:行者123 更新时间:2023-11-29 07:12:55 25 4
gpt4 key购买 nike

错误SQL查询:

UPDATE  `wfg_db`.`employee` SET  `DOB` = 
(DECLARE@mm INT
DECLARE@xm INT
SET @mm =1
SET @xm =13
DECLARE@md
INT DECLARE@xd
INT SET @md =1
SET @xd =29
DECLARE@my INT
DECLARE@xy INT
SET @my =1900
SET @xy =2009 SELECT CAST( CAST( (

@xm - @mm
) * RAND( ) + @mm AS INT ) AS VARCHAR( 2 ) ) + '/' + CAST( CAST( (
@xd - @md
) * RAND( ) + @md AS INT ) AS VARCHAR( 2 ) ) + '/' + CAST( CAST( (
@xy - @my
) * RAND( ) + @my AS INT ) AS VARCHAR( 4 ) ) AS DATE )
WHERE `employee`.`id`

MySQL 说:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE @mm int DECLARE @xm int SET @mm = 1 SET @xm = 13 DECLARE @md int ' at line 1

最佳答案

这是否满足您的需求?

 UPDATE  `wfg_db`.`employee` SET  `DOB` = 
cast(ADDDATE('1900-01-01',rand()*40176) as date)
/* WHERE `employee`.`id` = What?*/

关于sql - 如何在SQL中为表中的每一行随机输入DOB?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3386087/

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