这是我的查询。所以我需要从仅在组件 1 和 2009 年的预算元键的值中检索总和。我该怎么做。提前致谢
SELECT SUM(
b.meta_value)
, b.meta_key
FROM wp_posts AS p, wp_postmeta AS b, wp_postmeta AS m, wp_postmeta AS n
WHERE (
p.ID = b.post_id
)
AND (
b.meta_key = 'budget'
)
AND (
m.meta_key = 'component'
AND m.meta_value = '1'
)
AND (
n.meta_key = 'component-year'
AND n.meta_value = '2009'
)