0

Student_register table:

regNo 
pro(HNDIT,HNDA,HNDFT)
name
start_day
etc ... more columns 

Semester:

regNo
curSemmester(3,4,5)
name

The query I used to get values:

SELECT student_register.pro='HNDIT', student_register.regNo,sem.curSem =4,sem.name
FROM student_register
INNER JOIN sem
ON sem.regNo = student_register.regNo
ORDER BY sem.regNo;

I need to get regNo from student_register that according to pro = hndit or any other (hndft/HNDA) then I want to compare those regNo to current semester which that user define curSem=3 (4/5/6) regNo Numbers

Get student numbers who do HNDIT course and then get regNO from semester table that user define semester(3 or 4 or 5 ) student who do Course hndit:

student_register.pro='HNDIT' -> sem.curSem =4 -> regNo and name
2
  • kindly edit the question for better understanding Jan 26, 2015 at 7:18
  • what are the unclear areas
    – DanRox
    Jan 26, 2015 at 11:57

1 Answer 1

1

Suppose that you want sem3 then query will be

Case 1#

Select stureg.regno,stureg.pro,stureg.name,stureg.start_day,
sem.regno,sem.curSemmester,sem.name
from student_register as stureg left outer join semester as sem on stureg.regno=sem.regno
where stureg.pro REGEXP '^H' and sem.CurSemmester='3'

group by regno

order by regno
;

Case 2#

Select stureg.regno,stureg.pro,stureg.name,stureg.start_day,
sem.regno,sem.curSemmester,sem.name
from student_register as stureg left outer join semester as sem on stureg.regno=sem.regno
where stureg.pro like '%H%' and sem.CurSemmester='3'

group by regno

order by regno
;

Give it Try.

1
  • this work fine and thank you but their are little problem here i get resultset that with repeated columns like regNo and name how to avoid those and get only name and regNo thank you again for your help
    – DanRox
    Jan 26, 2015 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.