MYSQL: select latest record only (on left join table)

前端 未结 4 1294
时光说笑
时光说笑 2021-01-17 22:42

I have 2 tables:

Table1:

ID | Mobile Number | Name | Ordered Product| Order Date

Table2:

         


        
4条回答
  •  有刺的猬
    2021-01-17 23:29

    The best way to do it is to have CreatedAt and ModifiedAt fields in every table in database. Then you just add ORDER BY CreatedAd LIMIT 1. Not sure if your Time is what I mean.

    What you also have is ID. Now, if ID is AutoIncremental then job should be easy. Use ORDER BY id DESC LIMIT 1

提交回复
热议问题