I have 2 database tables:
servers
+----------+--------------+
| Field | Type |
+----------+--------------+
| id | int(11) |
| ip | varchar(255) |
| votes | int(11) |
| port | varchar(255) |
| hash | varchar(255) |
| created | datetime |
| modified | datetime |
+----------+--------------+
stats
+------------+--------------+
| Field | Type |
+------------+--------------+
| id | int(11) |
| server_id | int(11) |
| type | varchar(255) |
| hostname | varchar(255) |
| gamemode | varchar(255) |
| language | varchar(255) |
| players | int(11) |
| slots | int(11) |
| version | varchar(255) |
| url | varchar(255) |
| date_check | datetime |
| created | datetime |
| modified | datetime |
+------------+--------------+
I'm having trouble making the following selection rule:
Select the data from the servers table and join stats using servers.id = stats.server_id . But this join should only get the latest (only one) of the stats table that has type equal to online in> or offline .
How could the query be used to make this rule?