sql - 如何将长选择语句插入或更新到列中?
问题描述
所以我有这就是我想做的
我的表名称是 GameInvLoc,包含 3 列 ID、GameLoc、GameInv
ID GameLoc GameInv
1 Bre Null
我想做这个
Update GameInvLoc
set GameInv = 'select 'ROlID,Whse,Company,LocationNo' union all select concat(id,',',Whse,',',Company,',',LocationNo) from CINT..vwGameReport'
where id = 1
但我在引用时遇到问题,他们去哪里我得到语法错误。
有人知道这样做的正确方法吗?
解决方案
您必须使用单引号两次来表示字符串文字中的一个单引号。
像这样的东西:
Update GameInvLoc
set GameInv = 'select ''ROlID,Whse,Company,LocationNo'' union all select concat(id,'','',Whse,'','',Company,'','',LocationNo) from CINT..vwGameReport'
where id = 1
推荐阅读
- javascript - 为什么 Socket.io 没有在我的 React Native 应用程序中连接
- node.js - 节点'readline'如何检测当前行是文件中的最后一行
- mysql - C3P0 明显死锁
- maven - swt 库无法解析
- python - 烧瓶。应用工厂测试
- c++ - 如何在线比较2个excel文件
- ruby - 为什么'||' 运算符返回“[]”?
- wordpress - 如何使用 Google Analytics 编写一个在 WordPress 中捕获登录用户的维度?
- c# - Azure DevOps (VSTS) 在运行测试时找不到 Moq DLL
- wordpress - 没有链接的 Wordpress 管理员顶级菜单项