MySQL: selecting rows by two of three primary keys
<p>I am searching for exactly the opposite of what Jonathan was searching in this example:</p>

<p><a href="https://stackoverflow.com/questions/19230560/how-to-select-multiple-rows-by-multi-column-primary-key-in-mysql">How to select multiple rows by multi-column primary key in MySQL?</a></p>

<p>Having 3 columns as a primary key (the 3rd is a date), I want to select all of them without the most recent one. And if there is no second entry for a combination of the first two primary values, I don't want to select it at all. Think of it as a kind of versioning. The table-structure contains more columns than those three and i want to select the whole rows.</p>

<p>Looks something like that:</p>

<pre><code>{ID1 | ID2 | DATE} | more columns ...
</code></pre>

<p>Pseudocode:</p>

<pre><code>SELECT * FROM table WHERE (first and second primary value are the same and exist more than once) AND NOT MAX(date)
</code></pre>

<p>:D</p>

<p>I want to output the data of all previous versions of the row, not including the most recent one.</p>

<p>Thanks in advance for any suggestions!</p>