I have two tables. One is students and other one is results. Now student id in studetnt's table is unique but one student can have multiple rows in results table.
I want to join both tables and produce exactly one resulting row for every student. This row will contain student's info (name,image etc) and most recent student result.
I have applied inner join to achieve this but I am getting separate row for each entry in results table. If I apply limit 1 it gives me result with only one student's data and not every student's.
Here is the query:
SELECT students.id,
students.roll_num,
students.first_name,
students.middle_name,
students.last_name,
students.course,
students.photo_url,
results.parano,
results.grade
FROM students
RIGHT JOIN results ON results.std_id=students.id
And here is what I get in results: