I've got a Wordpress site where I have also got a couple of php pages outdoors of my Wordpress installation which I have to query the database that forces my Wordpress site. I've got a working query however it does not show things i actually need output.

Fundamental essentials two tables wordpress_posts and wordpress_postmeta

wp_posts
ID
post_author
post_date
post_date_gmt
post_content
post_title
post_excerpt
post_status
comment_status
pint_status
post_password
post_name
to_ping
pinged
post_modified
post_modified_gmt
post_content_filtered
post_parent
guid
menu_order
post_type
post_mine_type
comment_count

wp_postmeta
meta_id
post_id
meta_key
meta_value

which may be the query that demonstrate the publish publish:

$query = "SELECT post_title, post_name FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 5";

which may be the query that demonstrate using the meta_key= '_wordpress_attached_file'

$query ="SELECT post.ID, post.post_title, post.post_excerpt, post.post_content, meta.meta_value FROM wp_posts AS post INNER JOIN wp_postmeta AS meta ON meta.post_id = post.id AND meta.meta_key = '_wp_attached_file' ";

things i want would be to mix both of these query to exhibit publish_status ='publish' and also the meta_key = '_wordpress_attached_file'

this is actually the illustration of my query but does not show value

<?php
   $query ="SELECT post.ID, post.post_title, post.post_excerpt, post.post_content, meta.meta_value FROM wp_posts AS post INNER JOIN wp_postmeta AS meta ON meta.post_id = post.id AND meta.meta_key = '_wp_attached_file' WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 5 ";

    $result = mysql_query($query,$link);
        if(mysql_num_rows($result)) {
          while($post = mysql_fetch_object($result)) {
               echo "$post->meta_value";  
               echo "$post->post_title";
               echo "$post->post_content";
        }
        }
?>

thank you men.. .

one other issue it show only one publish and doesn't latest publish

here's my up-to-date code

<?php
$con = mysql_connect("localhost", "root", "");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

$db_selected = mysql_select_db("wp_db",$con);
$sql = "SELECT 
  posts.ID,
  posts.post_title AS title,
  posts.post_content AS content,
  files.meta_value AS filepath
FROM
  wp_posts posts
  INNER JOIN wp_posts attachments ON posts.ID = attachments.post_parent
  INNER JOIN wp_postmeta files ON attachments.ID = files.post_id
WHERE 1 = 1
  AND files.meta_key = '_wp_attached_file'";
$result = mysql_query($sql,$con);

while ($row = mysql_fetch_object($result))
  {
  echo $row->title . "<br />";
  }

mysql_close($con);
?>

will i go wrong with my code.. .thank for help many thanks.. .