MYSQL更新语句-未知列
我有一个可以与以下输出正确配合的选择查询:
我想创建一个更新语句设置 despgoods_alldetails.loadid 列的值 = loaddetails.loadid,其中 despgoods_alldetails_despgoodsid=loaddetails.despgoodsid.loadid。
我在想
更新 despgoods_alldetails 设置 despgoods_alldetails.loadid = loaddetails.loadid 其中 despgoods_alldetails.despgoodsid=loaddetails.despgoodsid
此查询失败并出现以下错误:
知道如何让此更新语句发挥作用吗?
谢谢, 瑞安
I have a select query which works correctly with the below output:
I would like to create an update statement to set the value of the despgoods_alldetails.loadid column = loaddetails.loadid where despgoods_alldetails_despgoodsid=loaddetails.despgoodsid.loadid.
I was thinking along the lines of
update despgoods_alldetails
set despgoods_alldetails.loadid = loaddetails.loadid
where despgoods_alldetails.despgoodsid=loaddetails.despgoodsid
This query fails with the below error:
any idea how I can get this update statement to work?
Thanks,
Ryan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
差不多了,你只需要参考第二个表。
Almost had it, you just need a reference to the second table.
loaddetails
是一个独立于您尝试更新的表的表。这不能直接在 SQL 更新中完成。您需要像这样的子选择:loaddetails
is a separate table from the one you are trying to update. This can't be done directly in a SQL update. You'll need a subselect like this instead:您需要在更新子句后放置两个表,如下所示
您可以在本页中找到一个简单的示例 http://dev.mysql.com/doc/refman/5.0/en/update.html
You need to put two tables after update clause like this
Can you found one simple example in this page http://dev.mysql.com/doc/refman/5.0/en/update.html