以下是MySQL查询:
SELECT `wp_fcfebce_postmeta`.`post_id`,
`wp_fcfebce_postmeta`.*
FROM `wp_fcfebce_posts`,`wp_fcfebce_postmeta`
WHERE `wp_fcfebce_postmeta`.`post_id`=`wp_fcfebce_posts`.`ID`
AND `wp_fcfebce_posts`.`post_date_gmt` > '2018-05-20 00:00:00'
AND `wp_fcfebce_posts`.`post_date_gmt` < '2018-05-20 23:59:59'
AND `wp_fcfebce_postmeta`.`meta_key`='_wp_attached_file'
我想更新meta_value
表格中wp_fcfebce_postmeta
列的匹配项,其中包含来自加入wp_fcfebce_posts
和wp_fcfebce_postmeta
表格的条件。
答案 0 :(得分:0)
假设您需要与select中相同的逻辑,但应用于更新,则可以尝试以下操作:
UPDATE wp_fcfebce_postmeta t1
INNER JOIN wp_fcfebce_posts t2
ON t1.post_id = t2.ID
SET t1.meta_value = 'some_value'
WHERE
t2.post_date_gmt >= '2018-05-20' AND
t2.post_date_gmt < '2018-05-21' AND
t1.meta_key = '_wp_attached_file';
请注意,我在WHERE
子句中重写了日期限制。