我有6个表来存储我的用户数据的MySQL从每一个表中获取用户最新数据
tbl_user_name
uuid | username | date (unix time)
-----------------------------------------
0 | lisha.s | 1489857236
1 | titami | 1485853232
2 | mathew | 1442853636 <----|> Users can change their username
3 | sandarjun | 1489857239 |> so i need to get the uuid by the
2 | mathew_kar | 1575456274 <----|> newest username which is given
tbl_user_fullname:
uuid | fullname | date (unix time)
-----------------------------------------
0 | Lisha Simonette | 1489857236
1 | Titus Amiran | 1481256345
2 | Mathew Karolina | 1489234455
3 | Sandhya Arjun | 1489857239
0 | Lisha Karolina | 1599999999
tbl_user_website:
uuid | website | date (unix time)
-----------------------------------------
0 | google.com | 1489857236
1 | titusamiran.com | 1489855234
2 | mathewk.net | 1489857432
3 | blod.sandhya.info | 1489857239
tbl_user_birthdate :
uuid | birthdate | date (unix time)
-----------------------------------------
0 | 02-05-1991 | 1489857236
1 | 05-08-1980 | 1489857123
2 | 09-09-1992 | 1489851334
3 | 17-02-1998 | 1489857239
tbl_user_follower:
uuid | follower_uuid
-----------------------
0 | 4
1 | 8
2 | 0
3 | 4
3 | 2
3 | 1
tbl_user_online:
uuid | last_seen (unix time)
-----------------------
0 | 1489855334
1 | 1589851111
2 | 1689857234
3 | 1789834539
我想收集的uuid,全名称,网站,出生日期和追随者的由用户与号码给定的用户名。 (我需要获取最新的用户名uuid,因为用户可以更改用户名)。
日期列是它们更改值时的时间戳。例如在tbl_user_fullname
:Lisha Simonette(uuid 0)与Mathew Karolina(uuid 2)结婚,所以我需要在日期列中获得Lisha(uuid 0)的新名称。等等......对于tbl_user_website
和tbl_user_birthdate
..即使他们不经常改变他们的生日;)
从表tbl_user_online
我只需要last_seen时间戳。
我给查询的值是用户名。用户名应该给出与我可以查询其他表的uuid。
非常感谢您的帮助和抱歉,我的英语不好;)
为什么每个表都有与之相关的时间戳?你尝试过什么吗? –
每个表都有一个时间戳,因为用户可以更改用户名和全名等值。所以我需要通过时间戳获取最新值。 – pfMusk
为什么你需要检索他们的用户名**使用**虽然?难道你不能只运行一个'UPDATE'而不是追加新行? –