I have a question about joining two tables with no relationship.
Students Table
Grades Table
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
CodePudding user response:
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
CodePudding user response:
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
CodePudding user response:
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;