Table students has 3 columns id, name, and class.
I want to select the matched row based on the condition for example if the student’s name is Jhon, plus the next 3 rows (without any condition) followed by the match row in just one query.
After research, my code below returns only 1 row, or maybe this is not the way of doing what I want:
SELECT * FROM `students` AS `parent`
INNER JOIN `students` AS `child`
WHERE `parent`.`name` = ? AND `child`.`id` > `parent`.`id`
ORDER BY `child`.`id` ASC LIMIT 3
Note: I am using PHP Prepared Statements.