Search Posts

How to fetch specific row from database using mysql

how to – How to fetch specific row from database using mysql

I have below mentioned table (sample):

ID        Value           Date
TT-12     call rs         2018-04-01 15:18:22
TT-12     srte er         2018-04-02 12:15:18
TT-12     efft rs         2018-04-03 13:04:08
TT-14     efft rs         2018-04-04 17:16:10
TT-14     call rs         2018-04-05 16:25:43
TT-14     srte rs         2018-04-06 21:11:47
TT-18     srte rs         2018-04-07 22:18:34
TT-18     call rs         2018-04-08 07:11:35
TT-18     call rs         2018-04-09 13:07:25

From the above table i want to fetch only those rows which has Value Call rs against particular ID with oldest time.

Required Output:

ID        Value           Date
TT-12     call rs         2018-04-01 15:18:22
TT-14     call rs         2018-04-05 16:25:43
TT-18     call rs         2018-04-08 07:11:35

I am trying: select ID,Value,Date from Table1 where ID in ('TT-12','TT-14','TT-18') and order by Value='call rs';

Source: Stackoverflow

Leave a Reply

Your email address will not be published. Required fields are marked *