mysql - How to select latest records less than value -
i have table named conductor. want select latest records date
less my_value
.
+----+-----------+------+ | id | program | date | +----+-----------+------+ | 1 | program 1 | 1 | | 2 | program 1 | 3 | | 3 | program 2 | 3 | | 4 | program 1 | 5 | | 5 | program 1 | 7 | +----+-----------+------+
if consider my_value
4 output be:
+----+-----------+------+ | id | program | date | +----+-----------+------+ | 2 | program 1 | 3 | | 3 | program 2 | 3 | +----+-----------+------+
how can select records sql?
select * conductor `date` = (select max(`date`) conductor `date` < myvalue )
Comments
Post a Comment