从页面中多次选择

I am using a code that reads pages from the database. It runs on PDO, PHP. Anyways I am wondering how would I make it so it reads from two tables? As if for example, at the current time it runs off 'pages' but could I make it also read pages from 'pages_default'. I dont mean as in it only displays pages that has both names in both tables but instead seperate tables with similar fields..

<?php


if (isset($_GET['p']))
{
    $stmt = $dbh->prepare('SELECT * FROM pages WHERE shortname = :p');
    if (!$stmt->execute(array(':p' => $_GET['p'])))
    {//
        exit('Could not exec query with param: '.$_GET['p']);
    }
    while($row = $stmt->fetch(PDO::FETCH_ASSOC))
    {
        echo '<font size="6pt">'.$row["title"].'</font><div class="hr"><hr /></div><br>';
        echo '   '.$row["content"].' ';
    }
}
//disconnect:
$dbh = null;
    ?>

Hoping that I have understood your question, I assume you want to run one query and retrieve rows from two tables with different names and fields.

You use the UNION operator in your query, and get rows from the two tables, and then unifying them into one table. You must get the same number and type of fields from every table, and give the same alias names to every field you get.

Let's say you have tables t1 and t2 and want to get 3 similar fields from each, with each table having the same condition (yours shortname=:p).

SELECT <field1>, <field2>, <field3> FROM ((SELECT <t1field1> AS <field1>, <t1field2> AS <field2>, <t1field3> AS <field3> 
FROM t1 WHERE <t1field2>=:p) UNION (SELECT <t2field1> AS <field1>, <t2field2> AS <field2>, <t2field3> AS <field3> FROM t2 WHERE <t2field2>=:p)) AS A

field1,field2,field3 are the aliases you set for the fields you retrieve, since the two tables may have different field names.