这是我的查询:
SELECT ID FROM wp_posts
WHERE post_type = 'vreb_property'
AND post_status = 'publish'
ORDER BY post_modified DESC
在这种情况下,我需要修改我的查询以包含 WHERE post_parent = ID
... 所以我需要使用正在选择的 ID。
SELECT ID FROM wp_posts WHERE post_type = 'vreb_property' ... 并选择 'post_parent' = ID 的记录
因为有一些属于post_type
“附件”的记录我需要抓取。
我能不能看几眼来澄清这个请求的有效性?谢谢。
最佳答案
您是在寻找OR
吗?
SELECT ID FROM wp_posts
WHERE (post_type = 'vreb_property'
AND post_status = 'publish')
OR (post_type = 'attachment'
AND post_parent = ID)
ORDER BY post_modified DESC
您可以使用括号使其适应您的特定需求,因为这并不完全清楚。
关于php - MySQL:选择列等于ID的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13963552/