How can I select rows from two tables that have slightly different columns? How can I offset them?
<p>I’m building a search function for a real estate app and I’m trying to display 100 filtered properties per page.</p>

<p>My SQL for the first load looks like this:</p>

<pre><code>$sql = "SELECT * FROM table WHERE bedrooms = 2 LIMIT 100";
</code></pre>

<p>Subsequent loads are basically the same with an additional offset. The offset is defined by the page number subtracted by one, multiplied by the properties per page.</p>

<pre><code>$page = $_GET[‘page’] - 1;
$propertiesPerPage = 100;
$offset = $page * $propertiesPerPage;

$sql = "SELECT * FROM table WHERE bedrooms = 2 LIMIT 100 OFFSET ".$offset;
</code></pre>

<p>This works great. Now I just want to do the same thing, but get properties from two tables instead of just one. I'm trying this:</p>

<pre><code>$sql = "SELECT * FROM table1 WHERE bedrooms = 2";
$sql .= " UNION ALL ";
$sql .= "SELECT * FROM table2 WHERE bedrooms = 2 LIMIT ".$propertiesPerPage." OFFSET ".$offset;
</code></pre>

<p>However, because each table has a few different columns than the other, I get this error:</p>

<p><code>The used SELECT statements have a different number of columns</code></p>

<p>Both tables have 60 or more columns but most of the columns are the same. 
Is there a way to select rows from both tables where <code>WHERE</code> conditions are met?</p>

<p>Also, how does <code>OFFSET</code> work with <code>JOIN</code>s? How can I "paginate" the results being selected from two tables?</p>