From what I understood, what you have to do is sort the records according to your criteria, in this case id_periodo
descending, then, you use LIMIT
to return the number of records you need.
For example;
Table and Records:
CREATE TABLE ejemplo (
id int NOT NULL AUTO_INCREMENT,
id_periodo int,
id_productos int,
PRIMARY KEY(id)
);
INSERT INTO ejemplo (id_periodo, id_productos)
values
("1","1"),
("1","2"),
("2","2"),
("2","1")
Query:
SELECT *
FROM ejemplo
ORDER BY id_periodo DESC
LIMIT 2
Result:
| id | id_periodo | id_productos |
|----|------------|--------------|
| 4 | 2 | 1 |
| 3 | 2 | 2 |
I leave the SQLFiddle so you can see it in practice
EDIT
After reading your comment, to do what you need, you can do a Subquery , it would be as follows;
SELECT *
FROM ejemplo
WHERE id_periodo = (SELECT max(id_periodo) from ejemplo)
Result
| id | id_periodo | id_productos |
|----|------------|--------------|
| 3 | 2 | 2 |
| 4 | 2 | 1 |
SQLFiddle