由于 SET 语句导致 SQL 查询失败 [关闭]
Posted
技术标签:
【中文标题】由于 SET 语句导致 SQL 查询失败 [关闭]【英文标题】:SQL Query failing due SET Statement [closed] 【发布时间】:2021-07-14 06:20:17 【问题描述】:这个查询有什么问题?
UPDATE
reinigung
SET
`val1` = '[["Datum","20.04.2021","Kalenderwoche",16,"","",""],["","Gerdorf","","Hartmannsdorf1","","Hartmannsdorf2",""],["Zeit","Kennz. Tank","Fahrer","Kennz. Tank","Fahrer","Kennz. Tank","Fahrer"],["00:00","","","","","",""],["01:00","","","","","",""],["02:00","","","","","",""],["03:00","","","","","",""],["04:00","","","","","",""],["05:00","","","","","",""],["06:00","","","","","",""],["07:00","","","","","",""],["08:00","","","","","",""],["09:00","","","","","",""],["10:00","","","","","",""],["11:00","","","","","",""],["12:00","","","","","",""],["13:00","","","","","",""],["14:00","","","","","",""],["15:00","","","ssssssss","","",""],["16:00","","","","","",""],["17:00","","","","","",""],["18:00","","","","","",""],["19:00","","","","","",""],["20:00","","","ss","","",""],["21:00","","","","","",""],["22:00","","","sssss","","",""],["23:00","","","","","",""]]',
SET
`val3` = 'test',
SET
`val6` = 'herrsanderschmidt@gmail.com',
SET
`val7` = '2021-04-20 06:05:01'
WHERE
`val2` = '2021-04-20'
【问题讨论】:
你确定那是 SQL Server 吗?在我看来更像 mysql。它给出了什么错误? 您的 SQL 语法有误;似乎错误就在附近:'SETval3
= 'test', SET val6
= 'herrsanderschmidt@gmail.com', SET 'val7' at line 5 ...我不明白为什么它失败了
Edit 它进入你的问题。并确认您使用的是哪个 RDBMS。
我不相信任何 SQL UPDATE
语句需要不止一次使用关键字 SET
- 我建议查看官方文档。
你确定这是SQL Server
吗?对我来说,这看起来不像 SQL Server
声明,也许是 MariaDB
或 MySql
之前问过的。请更正数据库标签
【参考方案1】:
只使用一个set
并使用comma
作为分隔符来更新多个值。并且不需要用 ``
UPDATE
reinigung
SET
val1 = '[["Datum","20.04.2021","Kalenderwoche",16,"","",""],["","Gerdorf","","Hartmannsdorf1","","Hartmannsdorf2",""],["Zeit","Kennz. Tank","Fahrer","Kennz. Tank","Fahrer","Kennz. Tank","Fahrer"],["00:00","","","","","",""],["01:00","","","","","",""],["02:00","","","","","",""],["03:00","","","","","",""],["04:00","","","","","",""],["05:00","","","","","",""],["06:00","","","","","",""],["07:00","","","","","",""],["08:00","","","","","",""],["09:00","","","","","",""],["10:00","","","","","",""],["11:00","","","","","",""],["12:00","","","","","",""],["13:00","","","","","",""],["14:00","","","","","",""],["15:00","","","ssssssss","","",""],["16:00","","","","","",""],["17:00","","","","","",""],["18:00","","","","","",""],["19:00","","","","","",""],["20:00","","","ss","","",""],["21:00","","","","","",""],["22:00","","","sssss","","",""],["23:00","","","","","",""]]',
,
val3 = 'test',
,
val6 = 'herrsanderschmidt@gmail.com',
,
val7 = '2021-04-20 06:05:01'
WHERE
val2 = '2021-04-20'
【讨论】:
非常感谢!我读了这么多,以至于我错过了那个简单的“一个”-单陈述事实。感谢您的快速帮助。 欢迎您:)以上是关于由于 SET 语句导致 SQL 查询失败 [关闭]的主要内容,如果未能解决你的问题,请参考以下文章
PDO lastInsertID() 由于在一次调用中运行多个查询而失败
由于空格,ADODB.Recordset 到 SQL Server 查询失败