Note that there are some explanatory texts on larger screens.

plurals
  1. PODetermine 'valid until' date in MySQL query
    primarykey
    data
    text
    <p>In this table I store changeable values for certain spids. As days go by, these values can change, and an spid can get a new value.</p> <p>Now I want to find out until when a certain value is enabled.</p> <p>This is the data for a single spids</p> <pre><code>uid spid propertyvalue creationdate -------------------------------------------------- 1 3 First name 2010-01-17 22:34:00 37 3 Second name 2010-01-18 01:07:24 38 3 Third name 2010-01-18 01:09:00 39 3 Fourth name 2010-01-18 01:18:16 40 3 Fifth name 2010-01-18 01:20:02 </code></pre> <p>So the first value starts at <strong>2010-01-18 01:07:24</strong> and would be valid until <strong>2010-01-18 01:01:00</strong>.</p> <p>I already tried this query:</p> <pre><code>SELECT s1 . * , s2.creationdate AS datetwo FROM salespointproperty s1 JOIN salespointproperty s2 ON s1.spid = s2.spid AND s1.creationdate &lt; s2.creationdate </code></pre> <p>That gives me a lot of double-records (some of them wrong), and it always leaves out the last new name (as it doesn't have a new creationdate following it) Example:</p> <pre><code>uid spid propertyvalue creationdate datetwo -------------------------------------------------------------- 1 3 First name 2010-01-17 22:34:00 2010-01-18 01:07:24 * 1 3 First name 2010-01-17 22:34:00 2010-01-18 01:09:00 37 3 Second name 2010-01-18 01:07:24 2010-01-18 01:09:00 * 1 3 First name 2010-01-17 22:34:00 2010-01-18 01:18:16 37 3 Second name 2010-01-18 01:07:24 2010-01-18 01:18:16 38 3 Third name 2010-01-18 01:09:00 2010-01-18 01:18:16 * 1 3 First name 2010-01-17 22:34:00 2010-01-18 01:20:02 37 3 Second name 2010-01-18 01:07:24 2010-01-18 01:20:02 38 3 Third name 2010-01-18 01:09:00 2010-01-18 01:20:02 39 3 Fourth name 2010-01-18 01:18:16 2010-01-18 01:20:02 * </code></pre> <p>Only the lines with an asterix are correct. The fifth name is missing.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload