Normally, I use this to query posts in specific categories:
<?php $recent = new WP_Query("cat=6,38&showposts=0"); while($recent->have_posts()) : $recent->the_post();?>
<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
<?php endwhile; ?>
but I need to query posts only if they are in BOTH of these categories categories.
Utkarsh Kukreti answers:
Use this
<?php $recent = new WP_Query(array('category__and' => array(6, 38))); while($recent->have_posts()) : $recent->the_post();?>
<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
<?php endwhile; ?>