Sql 需要嵌套while循环吗?

Sql 需要嵌套while循环吗?,sql,drupal,drupal-views,Sql,Drupal,Drupal Views,我已经编写了这段代码,但它只提取出与第一个查询中的一个值相匹配的第一个邻域组。代码位于Drupal视图中的节点ID PHP处理程序中 第一个查询将来自政府辖区的所有邮政编码放入一个数组中。第二个查询读取所有邻域组,以查找与该数组中的邻域组匹配的所有邻域组 看起来我需要第二个循环之类的东西,因为现在的while不能得到与数组中任何值匹配的每个邻域组。有人能看到我遗漏了什么吗 代码如下: 答案如下: foreach ($codes_list AS $value) { $results1 = db_

我已经编写了这段代码,但它只提取出与第一个查询中的一个值相匹配的第一个邻域组。代码位于Drupal视图中的节点ID PHP处理程序中

第一个查询将来自政府辖区的所有邮政编码放入一个数组中。第二个查询读取所有邻域组,以查找与该数组中的邻域组匹配的所有邻域组

看起来我需要第二个循环之类的东西,因为现在的while不能得到与数组中任何值匹配的每个邻域组。有人能看到我遗漏了什么吗

代码如下: 答案如下:

foreach ($codes_list AS $value)  {
$results1 = db_query("SELECT  nid FROM  {content_type_neighbourhood_group}  WHERE
field_postal_code_3_value = '%s'", $value);
while($return_list1 = db_fetch_array($results1)){
$neighbourhood_list[] = $return_list1[nid];
}
}
$neighbourhood_string = implode(', ', $neighbourhood_list);

return $neighbourhood_string;
答案是这样的:foreach($codes_list AS$value){$results1=db_query(“从{content_type_neighbourth_group}中选择nid,其中字段{u postal_code_3_value='%s',$value”);而($return_list1=db_fetch_array($results1)){$neighbourth_list[]=$return_list1[nid]}$neighbourth_string=intode(',',';返回$neighborhood_字符串;
foreach ($codes_list AS $value)  {
$results1 = db_query("SELECT  nid FROM  {content_type_neighbourhood_group}  WHERE
field_postal_code_3_value = '%s'", $value);
while($return_list1 = db_fetch_array($results1)){
$neighbourhood_list[] = $return_list1[nid];
}
}
$neighbourhood_string = implode(', ', $neighbourhood_list);

return $neighbourhood_string;