'How I join two tables with mysql? [closed]

I have a question about joining two tables with no relationship.

Students Table

enter image description here

Grades Table

enter image description here

I want to give Grade to each students, but I don't know how to join properly.

Is any good approach to join two table?

Thanks



Solution 1:[1]

maybe use a query like below

select s.*,g.grade from students s 
left join grades g on s.marks between min_mark and max_mark

Solution 2:[2]

Actually there is a relationship between marks and grade..so a join would be appropriate

Select id,name,marks,grade
    from student
    join grades on marks between min_mark and max_mark

Solution 3:[3]

There is a relationship, but it is not equals.
You could also use BETWEEN min_mark AND max_mark but you will need to check that your version of MySQL supports it.

SELECT
  s.ID,
  s.Name,
  s.Marks,
  g.grade
FROM
  Students s,
  Marks s
WHERE
  s.Marks >= g.Min_Mark
AND
  s.Marks <= g.max_Mark;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DhruvJoshi
Solution 2 P.Salmon
Solution 3