Now I would like to query data to do the newest get code.
Now I have 2 table,
this is t1.
+--------------+--------------------------+----------------------+
| id | name | description |
+--------------+--------------------------+----------------------+
| 1 | GG | GG is good |
| 2 | ABC DEFG | ABC DDDDD |
| 3 | CCARD | Gooooo |
+--------------+--------------------------+----------------------+
this is t2
+---------+------------+-------------------+------------------+
| id | kaid | code | timestamp |
+---------+------------+-------------------+------------------+
| 1 | 2 | ZZZZAAAAA | 123456789 |
| 2 | 2 | AAAZZADWWW | 123344444 |
| 3 | 1 | ASFASDFFFF | 123333333 |
| 4 | 2 | HHHHHFDFG | 123222222 |
| 5 | 1 | ASDASDADDDD | 123111111 |
+---------+------------+-------------------+------------------+
I want the data show like this:
ORDER BY timestamp desc limit 5
+--------+------------+------------------+------------------
| id | kaid | name | time |
+--------+------------+------------------+------------------+
| 1 | 1 | GG | 123111111 |
| 2 | 2 | ABC DEFG | 123222222 |
| 3 | 1 | GG | 123333333 |
| 4 | 2 | ABC DEFG | 123344444 |
| 5 | 2 | ABC DEFG | 123456789 |
+--------+------------+------------------+------------------+
now my code is:
$querylist = mysql_query("SELECT * FROM t1 ORDER BY time desc limit 5");
while($rowlist = mysql_fetch_row($querylist)) {
$idlist[] = $rowlist['id'];
$user_list_latest[] = $rowlist;
}
how do I select the t2.name when t1.id = t2.kaid?
thank you very much!