[英]How to update fields form a select statement in MySql with a WHERE clause?
[英]how do I update fields with a select for the where clause?
我有一張桌子,一張叫做“ articles”,另一張叫做“ links”。
我想從表鏈接中獲取url和標題,並使用鏈接表中的數據更新articles表。 我不確定該怎么做。 鏈接表引用了article_id,有人可以幫忙嗎?
如果有幫助,這里有一些偽代碼?
UPDATE articles
SET articles.url,
articles.title = (SELECT links.url,
links.title
FROM links
WHERE articles.id = links.article_id)
這有意義嗎?
UPDATE articles, links
SET articles.url = links.url,
articles.title = links.title
WHERE articles.id = links.article_id
要么
UPDATE articles
INNER JOIN links ON (articles.id = links.article_id)
SET articles.url = links.url,
articles.title = links.title
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.