How to get data from multiple table by datetime and conditions Mysql

  mysql, php, sql

I want to fetch data from three tables according to datetime(activity)

  1. "un_feeds" (User itself or other user can post feeds)
  2. "coin_review" (User itself or other can review/comment)
  3. "un_comments" (user itself or other can comment also)

But i want to get data with these conditions

  1. I have another table "un_user_follower",In this table we storing followers,So i want to get data of all person which i following
    from above three tables according to datetime(DESC ORDER/ MOST RECENT),In short same like facebook
  2. I have another table "un_coin_follow",In this table we storing list of coin which person/user follow,So i want to
    get data from above three tables (un_feeds,coin_review,un_comments) according to datetime(Most RECENT) on top

So in short i want "coins"(which i following) and "users"(which i following ) data/activity (except mine)according to datetime(Most RECENT on top)

Here is my three tables,My wallet_address is (1222xxxxx)

Table "un_feeds"

id              wallet_address              content             created_at
1               1222xxxxx                   Lorem1              1633597076
2               1233xxxxx                   Lorem2              1633598960              
3               1234xxxxx                   Lorem3              1633607928  
4               1233xxxxx                   Lorem4              1633690563

Table "coin_review"

id              wallet_address              Review              review_creation_time
1               1222xxxxx                   Lorem3              1634018103
2               1233xxxxx                   Lorem2              1633515708              
3               1234xxxxx                   Lorem3              1633438169  
4               1233xxxxx                   Lorem33             1633437127

Table "un_comments"

id              cmt_from                    cmt_to              comment                 review_creation_time
1               1222xxxxx                   1233xxxxx           Lorem1                      1634018103
2               1233xxxxx                   1222xxxxx           Lorem3                      1633515708              
3               1234xxxxx                   1233xxxxx           Lorem3                      1633438169  
4               1233xxxxx                   1234xxxxx           Lorem4                      1633437127

Table "un_user_follower"

id              from_wallet_address                 to_wallet_address                   
1               1222xxxxx                           1233xxxxx           
2               1222xxxxx                           1234xxxxx                           
3               1234xxxxx                           1233xxxxx           
4               1233xxxxx                           1235xxxxx   

    

Table "un_coin_follow" (key is coin_id)

id              name                                from_wallet_address                 
1               Lorem1                              1222xxxxx           
2               Lorem2                              1222xxxxx                           
3               Lorem3                              1222xxxxx           
4               Lorem4                              1222xxxxx

        

How can i get data according to Recent Activity (Most Recent on top),Thank you in advance

Source: Ask PHP

LEAVE A COMMENT