I am trying to retrieve the latest recorded value of a column in a table, using another table as reference.
i.e:
Table1
|id|Tnumid|
13 1
14 2
15 3
16 4
Table2
|id|Tnumid|PRnum|Timestamp
16 1 422 1455815894
17 2 560 1455815895
18 2 890 1455815896
19 3 450 1455815897
20 4 700 1455815898
Basically I want to use Table1 as reference, which contains a column value called Tnumid that never repeats (similarly to the id, but Tnumid doesn't skip a value). I want to retrieve the latest recorded value of PRnum on the second table.
Basically the output I want in the example above would be:
|id||Tnumid|Prnum|
16 1 422
18 2 890
19 3 450
20 4 700
Note how the latest recorded value is chosen in the case of Tnum=2.
So I want to SELECT PRnum from Table2, but I need to retrieve exactly the number of values of Tnumid, always choosing the latest recorded value. How can do this with a JOIN statement or something similar...? I am new to MySQL. Thanks a lot.