gpt4 book ai didi

mysql - 两个内部联接和第一个子句的 where

转载 作者:行者123 更新时间:2023-11-29 08:48:26 26 4
gpt4 key购买 nike

我有以下 SQL:

SELECT * FROM wp_postmeta 
INNER JOIN wp_term_relationships ON wp_postmeta.post_id = wp_term_relationships.object_id AND wp_term_relationships.term_taxonomy_id = '10'
INNER JOIN wp_posts ON wp_postmeta.post_id = wp_posts.id WHERE wp_posts.post_date BETWEEN CONCAT(CURDATE(),' 10:00:00') AND CONCAT(CURDATE(),' 18:00:00')
WHERE wp_postmeta.meta_key = '_shipping_country' AND wp_postmeta.meta_value IN ('AU', 'US', 'JP', 'BR', 'UK')
ORDER BY wp_postmeta.post_id DESC

它不起作用的任何原因,但如果我删除第二个 INNER JOIN 它工作正常吗?

最佳答案

在内连接条件中不能有 WHERE

SELECT * FROM wp_postmeta 

INNER JOIN wp_term_relationships ON wp_postmeta.post_id = wp_term_relationships.object_id AND wp_term_relationships.term_taxonomy_id = '10'
INNER JOIN wp_posts ON wp_postmeta.post_id = wp_posts.id AND wp_posts.post_date BETWEEN CONCAT(CURDATE(),' 10:00:00') AND CONCAT(CURDATE(),' 18:00:00')
WHERE wp_postmeta.meta_key = '_shipping_country' AND wp_postmeta.meta_value IN ('AU', 'US', 'JP', 'BR', 'UK')
ORDER BY wp_postmeta.post_id DESC

关于mysql - 两个内部联接和第一个子句的 where,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11935081/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com