Subscribe
| 10/10 | ___3 | NULL | NULL |
| 10/09 | NULL | NULL | NULL |
| 10/08 | NULL | ___2 | NULL |
| 10/07 | NULL | ___5 | NULL |
| 10/06 | ___4 | NULL | ___7 |
entry_date <= 10/08 AND column_name LIKE 'columnA' LIMIT 1 to get back the value "4" for input "10/08".id d c1 c2 c3
1 2001-01-01 00:00:00.0 1 1 1
2 2001-01-02 00:00:00.0 2 <null> <null>
3 2001-01-03 00:00:00.0 <null> 3 <null>
4 2001-01-04 00:00:00.0 <null> <null> 4
5 2001-01-05 00:00:00.0 <null> <null> <null>
6 2001-01-06 00:00:00.0 <null> <null> 6
7 2001-01-07 00:00:00.0 <null> <null> 7
8 2001-01-08 00:00:00.0 <null> 8 <null>
9 2001-01-09 00:00:00.0 <null> <null> 9
10 2001-01-10 00:00:00.0 10 <null> <null>
id select_type table type key rows extra
1 PRIMARY a ALL PRIMARY 10 Using temporary; Using filesort
1 PRIMARY b ALL <null> 10 Using where
1 PRIMARY a eq_ref PRIMARY 1
1 PRIMARY b ALL <null> 10 Using where
1 PRIMARY a eq_ref PRIMARY 1
1 PRIMARY b ALL <null> 10 Using where
4 DEPENDENT SUBQUERY a eq_ref PRIMARY 4 Using where
4 DEPENDENT SUBQUERY b ALL 10 Using where
3 DEPENDENT SUBQUERY a eq_ref PRIMARY 4 Using where
3 DEPENDENT SUBQUERY b ALL 10 Using where
2 DEPENDENT SUBQUERY a eq_ref PRIMARY 4 Using where
2 DEPENDENT SUBQUERY b ALL 10 Using where
id select_type table type key rows extra
1 PRIMARY a ALL <null> 10 Using temporary; Using filesort
1 PRIMARY b ALL <null> 10 Using where
1 PRIMARY c ALL <null> 10 Using where
1 PRIMARY d ALL <null> 10 Using where
4 DEPENDENT SUBQUERY a eq_ref PRIMARY 1 Using where; Using temporary; Using filesort
4 DEPENDENT SUBQUERY b ALL <null> 10
4 DEPENDENT SUBQUERY c ALL <null> 10
4 DEPENDENT SUBQUERY d ALL <null> 10 Using where
3 DEPENDENT SUBQUERY a eq_ref PRIMARY 1 Using where; Using temporary; Using filesort
3 DEPENDENT SUBQUERY b ALL <null> 10
3 DEPENDENT SUBQUERY c ALL <null> 10 Using where
3 DEPENDENT SUBQUERY d ALL <null> 10 Using where
2 DEPENDENT SUBQUERY a eq_ref PRIMARY 1 Using where; Using temporary; Using filesort
2 DEPENDENT SUBQUERY b ALL <null> 10 Using where
2 DEPENDENT SUBQUERY c ALL <null> 10
2 DEPENDENT SUBQUERY d ALL <null> 10 Using where
You are not logged in, either login or create an account to post comments
column_namenon_null_value
entry_date
With the example above, you'd end up with:
columnA | 3 | 10/10columnB | 2 | 10/08
columnB | 5 | 10/07
columnA | 4 | 10/06
columnC | 7 | 10/06
For input 10/08, to get back "4" for the first column, you just do a SELECT on this table, where
entry_date <> to get the first result. Repeat for the remaining columns. If the table is indexed the searches should run quickly.>posted by Blazecock Pileon at 11:18 AM on March 13