title: get post data from wordpress by sql query
body: <p>I want to get wordpress post data and get wp_attached_file from wp_postmeta table
  this is my sql query</p>
  
  <pre><code>$query= mysql_query("SELECT wp_posts.ID,wp_posts.post_title,wp_posts.post_date,wp_postmeta.meta_value 
                  FROM wp_posts
  
                    JOIN wp_term_relationships
                          ON wp_term_relationships.object_id = wp_posts.ID
  
                      JOIN wp_postmeta
                          ON wp_postmeta.post_id = wp_posts.ID
  
                  WHERE wp_posts.post_date &gt; '$before7' 
                  AND wp_posts.post_status = 'publish' 
                  AND wp_posts.post_type = 'post' 
                  AND wp_term_relationships.term_taxonomy_id = '$cat' 
                  AND wp_postmeta.meta_key = '_wp_attached_file' 
                  ORDER BY wp_posts.post_date DESC LIMIT 10");
  </code></pre>
  
  <p>it give me nothing but if I removed this line from where clause</p>
  
  <pre><code>AND wp_postmeta.meta_key = '_wp_attached_file'
  </code></pre>
  
  <p>it works but I need this line to get wp_attached_file</p>
  
  <p>so what is wrong with mysql query</p>