SQLiteException:靠近“If”:语法错误
我正在将“SQL Server 2008”存储过程转换为“SQLite”。 但面临以下查询的问题:
If (Select Count(UserId) From Users Where RememberMe = 'True') > 1
Update Users Set RememberMe = 'False'
Select UserName From Users Where RememberMe = 'True'
在“SQLite Administrator”或“SQLite Expert”中执行上述查询时,我收到以下错误消息:
发生错误:“If”附近:语法错误
我是 SQLite 的初学者。 请指导我。
谢谢&问候,
I am converting a 'SQL Server 2008' stored procedure to 'SQLite'.
But facing problem with the following query:
If (Select Count(UserId) From Users Where RememberMe = 'True') > 1
Update Users Set RememberMe = 'False'
Select UserName From Users Where RememberMe = 'True'
While executing the above query in the 'SQLite Administrator' or 'SQLite Expert', I am getting the following error message:
Error occured: near "If": syntax error
I am a beginner in SQLite.
Please guide me.
Thanks & Regards,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SQLite 不支持存储过程。
但看起来您的代码只更新用户表,为将 RememberMe 设置为“True”的用户设置 RememberMe =“False”。如果是这种情况,那么您根本不需要执行 If 部分。这应该足够了:
UPDATE Users SET RememberMe = 'False' WHERE RememberMe = 'True'
;SQLite doesn't support stored procedures.
But it looks like your code only updates the Users table to set RememberMe = 'False' for users that had it set to 'True'. If this is the case, then you don't need to do the If part at all. This should suffice:
UPDATE Users SET RememberMe = 'False' WHERE RememberMe = 'True'
;Sqlite 不支持
if
。您可以使用CASE
代替它。Sqlite does not support
if
. You can useCASE
instead of it.