I want to select the last rows of a specific table containing 5 elements in MySQL. The table looks like this:
- id (auto increase)
- at
- from
- time stamp
- text
The data looks something like this:
|id | to | from | time stamp | text
| 1 | user01 | user02 | 2011-09-01 | text1
| 2 | user01 | user02 | 2011-09-02 | text2
| 3 | user02 | user01 | 2011-09-02 | text3
| 4 | user01 | user03 | 2011-09-03 | text4
| 5 | user01 | user04 | 2011-09-03 | text5
| 6 | user01 | user03 | 2011-09-04 | text6
| 7 | user03 | user01 | 2011-09-05 | text7
I want the select * WHERE to = 'user01'latest data (perhaps by "id" or "timestamp"). "From" can be numerous, but each of the "data" can appear only once.
In any case, the selected data will be:
| 2 | user01 | user02 | 2011-09-02 | text2
| 5 | user01 | user04 | 2011-09-03 | text5
| 6 | user01 | user03 | 2011-09-04 | text6
Can this be done? Thanks for taking the time to my question :)
source
share