mysql - Get latest entry of a specific column value -
i have table (called btb
) multiple entries need ones beitragid
. fields specific beitragid
same, except bid
.
bid | title | beitragid ---------|--------|------------- 102 | blabla1 | 1013 1054 | blabla2 | 1013 1678 | blabla3 | 1013 104 | blublu1 | 1213 1058 | blublu2 | 1213 1668 | blublu3 | 1213 ...
since there no field in creation date noted , assume there no sql functionality detect recent entry without date field, want row highest bid
.
i'm struggeling correct sql query. got far:
select title btb beitragid = '1013' or beitragid = '1213'
if build group can use aggregate function max()
highest value of each group
select t1.* btb t1 join ( select max(bid) bid, beitragid btb beitragid in (1013, 1213) group beitragid ) t2 on t1.bid = t2.bid , t1.beitragid = t2.beitragid
Comments
Post a Comment