I’ve 2 tables:
nameTable
- userName
- userId
- classId
marksTable
- userId
- classId
- courseCode
- marks
i want to display userId, userName, courseCode, marks of all the students having same classId.
create proc mark__classId
@classId int
as
select marksTable.courseCode, marksTable.userId, marksTable.marks, nameTable.userName
from marksTable, nameTable
where
marksTable.classId = nameTable.classId
but this query gave very vague o/p.
Suppose “name1” with id NAME1 with classId 10 follows courseCode ‘C1, C2, C3’ with respective marks ‘80,99,90’
now I want to display all this information when I give input as
exec mark__classId 10
Your select should be more like this, you just need to use your incoming parameters. As well as you should be using a
JOINinstead of aCROSS JOINwith a filter