Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php MySQL:选择列等于ID的行_Php_Mysql_Wordpress - Fatal编程技术网

Php MySQL:选择列等于ID的行

Php MySQL:选择列等于ID的行,php,mysql,wordpress,Php,Mysql,Wordpress,这是我的疑问: SELECT ID FROM wp_posts WHERE post_type = 'vreb_property' AND post_status = 'publish' ORDER BY post_modified DESC 在这个场景中,我需要修改我的查询以包括WHERE post\u parent=ID。。。所以要选择的ID,我需要使用 从wp_posts中选择ID,其中post_type='vreb_property'。。。还可以选择“post_parent”=ID

这是我的疑问:

SELECT ID FROM wp_posts 
WHERE post_type = 'vreb_property'
AND post_status = 'publish' 
ORDER BY post_modified DESC
在这个场景中,我需要修改我的查询以包括
WHERE post\u parent=ID
。。。所以要选择的ID,我需要使用

从wp_posts中选择ID,其中post_type='vreb_property'。。。还可以选择“post_parent”=ID

因为有
post\u类型的记录
“附件”我需要抓取


我可以看几眼来澄清这个请求的有效性吗?谢谢。

您是在找
还是

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

使用括号可以根据您的具体需要进行调整,因为这还不完全清楚。

您是在寻找
还是

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

使用括号,您可以根据您的具体需要对其进行调整,因为这并不完全清楚。

我同意jeroen的sql,诀窍在括号中。

我同意jeroen的sql,诀窍在括号中。

您在查询中传递的已知id?嗯,比这稍微复杂一些。。。我在上面编辑了我的问题。你在查询中传递的一个已知id?嗯,比这个稍微复杂一点。。。我编辑了上面的问题。不幸的是,这只返回了一些结果。。。条件是
post\u parent=ID
,但需要返回的不仅仅是匹配
post\u类型='vreb\u属性'和post\u状态='publish'
的行,还有那些匹配
post\u类型='attachment'和post\u parent=ID
@dclumbus的行。这只是对条件的一个小改动,请参见我的编辑。诀窍在括号中。不幸的是,这仍然只返回10个结果。。。因此,为了澄清,我需要在结果中同时考虑这两种情况
post_type='vreb_property'和post_status='publish'
以及
post_type='attachment'和post_parent=ID
@dclombus这正是此查询所选择的。如果没有给出所需的结果,您应该发布完整的实际代码和未选择行的示例。它只提供
vrebu属性
行。。。没有属于附件的附加行
。。。我知道有几十个。不幸的是,这只返回了几个结果。。。条件是
post\u parent=ID
,但需要返回的不仅仅是匹配
post\u类型='vreb\u属性'和post\u状态='publish'
的行,还有那些匹配
post\u类型='attachment'和post\u parent=ID
@dclumbus的行。这只是对条件的一个小改动,请参见我的编辑。诀窍在括号中。不幸的是,这仍然只返回10个结果。。。因此,为了澄清,我需要在结果中同时考虑这两种情况
post_type='vreb_property'和post_status='publish'
以及
post_type='attachment'和post_parent=ID
@dclombus这正是此查询所选择的。如果没有给出所需的结果,您应该发布完整的实际代码和未选择行的示例。它只提供
vrebu属性
行。。。没有属于附件的附加行
。。。我知道有几十个。