将数据插入到由 JOIN SELECT QUERY 产生的表中? [英] insert data into table that results from a JOIN SELECT QUERY?
本文介绍了将数据插入到由 JOIN SELECT QUERY 产生的表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将数据插入到由 JOIN SELECT 查询产生的表中
How can I insert data to a table that results from a JOIN SELECT query
我想将下面查询结果中的值 ="ok" 插入到 b.URL 中
I'd like to insert into b.URL the value ="ok" from the result of the query below
SELECT
a.ESN,
b.URL,
a.Status,
a.GroupID,
a.RouteID
FROM STx a
LEFT JOIN Routes b
ON a.RouteID = b.RouteID
WHERE a.GroupID = 39
AND a.Status = "Tested"
order by a.ESN;
推荐答案
我想这也许就是你所需要的:
I think maybe this is what you need:
UPDATE Routes b
SET URL = 'ok'
WHERE EXISTS
(SELECT * FROM STx a
WHERE a.GroupID = 39
AND a.Status = 'Tested'
AND a.RouteID = b.RouteID)
这会将所需的 URL 值设置为确定".
This will set the desired URL values to 'ok'.
这篇关于将数据插入到由 JOIN SELECT QUERY 产生的表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文